Skip to content

Commit c0f43f4

Browse files
committed
Keep cursor position if already at jump location
If you position the cursor over a variable in anticipation of hitting the breakpoint to inspect it, it's a bit annoying if it jumps to the first column.
1 parent f9cac91 commit c0f43f4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lua/dap/session.lua

+6
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,12 @@ local function jump_to_location(bufnr, line, column)
393393
if column == 0 then
394394
column = 1
395395
end
396+
local cur_buf = api.nvim_get_current_buf()
397+
if cur_buf == bufnr and api.nvim_win_get_cursor(0)[1] == line and column == 1 then
398+
-- A user might have positioned the cursor over a variable in anticipation of hitting a breakpoint
399+
-- Don't move the cursor to the beginning of the line if it's in the right place
400+
return
401+
end
396402
for _, win in pairs(api.nvim_tabpage_list_wins(0)) do
397403
if api.nvim_win_get_buf(win) == bufnr then
398404
set_cursor(win, line, column)

0 commit comments

Comments
 (0)