feat: utilize last window cursor position (#2416)

closes #2386
This commit is contained in:
James Trew
2023-03-21 13:32:11 -04:00
committed by GitHub
parent 10ebb30f0d
commit 98f9d5f948

View File

@@ -110,7 +110,7 @@ action_set.edit = function(prompt_bufnr, command)
-- TODO: Check for off-by-one -- TODO: Check for off-by-one
row = entry.row or entry.lnum row = entry.row or entry.lnum
col = vim.F.if_nil(entry.col, 1) col = entry.col
elseif not entry.bufnr then elseif not entry.bufnr then
-- TODO: Might want to remove this and force people -- TODO: Might want to remove this and force people
-- to put stuff into `filename` -- to put stuff into `filename`
@@ -169,6 +169,11 @@ action_set.edit = function(prompt_bufnr, command)
end end
end end
if row == nil or col == nil then
local pos = vim.api.nvim_win_get_cursor(0)
row, col = pos[1], pos[2] + 1
end
if row and col then if row and col then
local ok, err_msg = pcall(a.nvim_win_set_cursor, 0, { row, col }) local ok, err_msg = pcall(a.nvim_win_set_cursor, 0, { row, col })
if not ok then if not ok then