diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-03-22 10:21:43 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2024-03-22 10:23:28 +0100 |
| commit | e44ec3fa609fa7701de369939674a1ea46743ea8 (patch) | |
| tree | 300775cd90cfac944922c03099c59979ec1615c1 /init.lua | |
| parent | 418167354031ae75c55042574764745a7a825e8f (diff) | |
| download | vis-lspc-apply-workspaceEdit-remember-cursor.tar.gz vis-lspc-apply-workspaceEdit-remember-cursor.zip | |
restore the primary cursor position after a workspaceEditapply-workspaceEdit-remember-cursor
Diffstat (limited to 'init.lua')
| -rw-r--r-- | init.lua | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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') |
