From: Magnus Groß Date: Mon, 4 Sep 2023 15:50:12 +0000 (+0200) Subject: Do not reset cursor after workspaceEdit X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=33c9dc37bd354391579f669a142699801b13d571;p=vim-lsp.git Do not reset cursor after workspaceEdit The workspace edit may add or delete lines, so resetting it to the last linenumber and column will very likely not match the last logical line before the workspaceEdit operation. For example an action might add an auto-import statement at the top of the file, effectively adding one line in-between. If we now reset the cursor, we will end up one logical line before the one where we actually started at. This behaviour is automatically fixed if we just don't reset the cursor at all. --- diff --git a/autoload/lsp/textedit.vim b/autoload/lsp/textedit.vim index 0ea69fb..2fe2ad0 100644 --- a/autoload/lsp/textedit.vim +++ b/autoload/lsp/textedit.vim @@ -213,7 +213,6 @@ export def ApplyWorkspaceEdit(workspaceEdit: dict) return endif - var save_cursor: list = getcurpos() for [uri, changes] in workspaceEdit.changes->items() var bnr: number = util.LspUriToBufnr(uri) if bnr == 0 @@ -224,8 +223,6 @@ export def ApplyWorkspaceEdit(workspaceEdit: dict) # interface TextEdit ApplyTextEdits(bnr, changes) endfor - # Restore the cursor to the location before the edit - save_cursor->setpos('.') enddef # vim: tabstop=8 shiftwidth=2 softtabstop=2