From bb985625db4167f988f1c90d9ddabc326d76bede Mon Sep 17 00:00:00 2001 From: Mike <10135646+mikesmithgh@users.noreply.github.com> Date: Sat, 14 Oct 2023 23:23:39 -0400 Subject: [PATCH] fix: set initial cursor position on pastewin close (#34) --- lua/kitty-scrollback/windows.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/kitty-scrollback/windows.lua b/lua/kitty-scrollback/windows.lua index 316b9cc5..d7dd7089 100644 --- a/lua/kitty-scrollback/windows.lua +++ b/lua/kitty-scrollback/windows.lua @@ -86,9 +86,15 @@ M.open_paste_window = function(start_insert) } end - vim.fn.cursor(p.pos.win_first_line, 1) local lnum = p.pos.cursor_line - p.pos.win_first_line - 1 local col = p.pos.col + 1 + + -- TermEnter may position cursor at the end of file with extra blank lines + -- Adjust cursor to hide blank lines and move cursor to initial position set by set_cursor_position + vim.fn.cursor(p.pos.win_first_line, 1) + vim.cmd.redraw() + vim.fn.cursor(p.pos.cursor_line, col) + if not p.paste_bufid then p.paste_bufid = vim.api.nvim_create_buf(false, false) vim.api.nvim_buf_set_name(p.paste_bufid, vim.fn.tempname() .. '.ksb_pastebuf')