Skip to content

Commit d451c30

Browse files
authored
repl: Move cursor to end of line on history selection (up/down) (#951)
Makes the behavior more consistent with other REPLs (ipython, bash, zsh, ...)
1 parent 6cedcb5 commit d451c30

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lua/dap/repl.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ local function select_history(delta)
334334
end
335335
local text = history.entries[history.idx]
336336
if text then
337-
local lnum = vim.fn.line('$') - 1
338-
api.nvim_buf_set_lines(repl.buf, lnum, lnum + 1, true, {'dap> ' .. text })
337+
local lnum = vim.fn.line('$')
338+
api.nvim_buf_set_lines(repl.buf, lnum - 1, lnum, true, {'dap> ' .. text })
339+
vim.fn.setcursorcharpos({ lnum, vim.fn.col('$') }) -- move cursor to the end of line
339340
end
340341
end
341342

0 commit comments

Comments
 (0)