From ae3252b4352b767a177c2e2be826928fae7a2390 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Mon, 15 May 2023 10:49:18 -0400 Subject: [PATCH 1/2] repl: Move cursor to the end of line on select_history (up/down) --- lua/dap/repl.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/dap/repl.lua b/lua/dap/repl.lua index de4c8cce..64c48525 100644 --- a/lua/dap/repl.lua +++ b/lua/dap/repl.lua @@ -336,6 +336,7 @@ local function select_history(delta) if text then local lnum = vim.fn.line('$') - 1 api.nvim_buf_set_lines(repl.buf, lnum, lnum + 1, true, {'dap> ' .. text }) + vim.fn.setcursorcharpos({ vim.fn.line('$'), vim.fn.col('$') }) -- move cursor to the end of line end end From 9b165073b9c1e952bc66499c6d45a043b8dd5ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fu=C3=9Fenegger?= Date: Wed, 17 May 2023 20:46:25 +0200 Subject: [PATCH 2/2] Update lua/dap/repl.lua --- lua/dap/repl.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/dap/repl.lua b/lua/dap/repl.lua index 64c48525..d1fb26cf 100644 --- a/lua/dap/repl.lua +++ b/lua/dap/repl.lua @@ -334,9 +334,9 @@ local function select_history(delta) end local text = history.entries[history.idx] if text then - local lnum = vim.fn.line('$') - 1 - api.nvim_buf_set_lines(repl.buf, lnum, lnum + 1, true, {'dap> ' .. text }) - vim.fn.setcursorcharpos({ vim.fn.line('$'), vim.fn.col('$') }) -- move cursor to the end of line + local lnum = vim.fn.line('$') + api.nvim_buf_set_lines(repl.buf, lnum - 1, lnum, true, {'dap> ' .. text }) + vim.fn.setcursorcharpos({ lnum, vim.fn.col('$') }) -- move cursor to the end of line end end