From 98f9d5f9482a8e2bc74074d9b03941d0b79782e5 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Tue, 21 Mar 2023 13:32:11 -0400 Subject: [PATCH] feat: utilize last window cursor position (#2416) closes #2386 --- lua/telescope/actions/set.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/telescope/actions/set.lua b/lua/telescope/actions/set.lua index 6e12907..c479324 100644 --- a/lua/telescope/actions/set.lua +++ b/lua/telescope/actions/set.lua @@ -110,7 +110,7 @@ action_set.edit = function(prompt_bufnr, command) -- TODO: Check for off-by-one row = entry.row or entry.lnum - col = vim.F.if_nil(entry.col, 1) + col = entry.col elseif not entry.bufnr then -- TODO: Might want to remove this and force people -- to put stuff into `filename` @@ -169,6 +169,11 @@ action_set.edit = function(prompt_bufnr, command) 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 local ok, err_msg = pcall(a.nvim_win_set_cursor, 0, { row, col }) if not ok then