aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorFlorian Fischer <gitlab@muhq.space>2024-04-08 17:35:25 +0000
committerFlorian Fischer <gitlab@muhq.space>2024-04-08 17:35:25 +0000
commitd36c417bc662a720a0bfdd60cbc8c1dc6c915041 (patch)
treee5d92f9779cdd18d34f459e523247fb7f28d274a /init.lua
parentac7bdc1f1a84d9e7bbd28f091700993362b72525 (diff)
parente44ec3fa609fa7701de369939674a1ea46743ea8 (diff)
downloadvis-lspc-d36c417bc662a720a0bfdd60cbc8c1dc6c915041.tar.gz
vis-lspc-d36c417bc662a720a0bfdd60cbc8c1dc6c915041.zip
Merge branch 'apply-workspaceEdit-remember-cursor' into 'main'
restore the primary cursor position after a workspaceEdit See merge request muhq/vis-lspc!47
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index a97db10..54ea67a 100644
--- a/init.lua
+++ b/init.lua
@@ -548,7 +548,7 @@ local function vis_apply_workspaceEdit(_, _, workspaceEdit)
end
end
- -- It is not open currently -> open it
+ -- The file is not currently opened -> open it
local opened
if not win_with_file then
vis_open_file(path, 'o')
@@ -556,10 +556,18 @@ local function vis_apply_workspaceEdit(_, _, workspaceEdit)
opened = true
end
+ -- Remember the current primary cursor position
+ local old_pos = win_with_file.selection.pos
+
for _, edit in ipairs(edits) do
vis_apply_textEdit(win_with_file, win_with_file.file, edit)
end
+ -- Restore the remembered primary cursor position
+ if lspc.workspace_edit_remember_cursor then
+ win_with_file.selection.pos = old_pos
+ end
+
-- save changes and close the opened window
if opened then
vis:command('wq')