Skip to content

Commit

Permalink
fix: set initial cursor position on pastewin close (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh authored Oct 15, 2023
1 parent 3e6a847 commit bb98562
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/kitty-scrollback/windows.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit bb98562

Please sign in to comment.