mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
feat: follow end of cursor that is being moved
This commit is contained in:
parent
8a93fb5dc2
commit
a98763217a
1 changed files with 9 additions and 1 deletions
|
@ -32,6 +32,8 @@ local function fetch_workspaces_list()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local last_jump = { 0, 0 }
|
||||||
|
|
||||||
---@param ws Workspace
|
---@param ws Workspace
|
||||||
local function register_cursor_callback(ws)
|
local function register_cursor_callback(ws)
|
||||||
local controller = ws.cursor
|
local controller = ws.cursor
|
||||||
|
@ -133,8 +135,14 @@ local function register_cursor_handler(ws)
|
||||||
if curr_buf ~= buf_id then
|
if curr_buf ~= buf_id then
|
||||||
vim.api.nvim_win_set_buf(win, buf_id)
|
vim.api.nvim_win_set_buf(win, buf_id)
|
||||||
end
|
end
|
||||||
|
-- keep centered the cursor end that is currently being moved, but prefer start
|
||||||
|
if event.start[1] == last_jump[1] and event.start[2] == last_jump[2] then
|
||||||
|
vim.api.nvim_win_set_cursor(win, { event.finish[1] + 1, event.finish[2] })
|
||||||
|
else
|
||||||
vim.api.nvim_win_set_cursor(win, { event.start[1] + 1, event.start[2] })
|
vim.api.nvim_win_set_cursor(win, { event.start[1] + 1, event.start[2] })
|
||||||
end
|
end
|
||||||
|
last_jump = event.start
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue