]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Don't add two entries to the jump list when jumping to a symbol in another file
authorAndreas Louv <andreas@louv.dk>
Sun, 19 Mar 2023 18:29:50 +0000 (19:29 +0100)
committerAndreas Louv <andreas@louv.dk>
Sun, 19 Mar 2023 18:29:50 +0000 (19:29 +0100)
autoload/lsp/util.vim

index 0e18dcf44b08120f1defb5d263d9195d5570a3b6..9343d4e0008d38f0d34fe3506786d094e59ed8bb 100644 (file)
@@ -172,7 +172,11 @@ export def JumpToLspLocation(location: dict<any>, cmdmods: string)
   # jump to the file and line containing the symbol
   if cmdmods == ''
     var bnr: number = fname->bufnr()
-    if bnr != bufnr()
+    if bnr == bufnr()
+      # Set the previous cursor location mark. Instead of using setpos(), m' is
+      # used so that the current location is added to the jump list.
+      normal m'
+    else
       var wid = fname->bufwinid()
       if wid != -1
         wid->win_gotoid()
@@ -201,9 +205,6 @@ export def JumpToLspLocation(location: dict<any>, cmdmods: string)
   else
     exe $'{cmdmods} split {fname}'
   endif
-  # Set the previous cursor location mark. Instead of using setpos(), m' is
-  # used so that the current location is added to the jump list.
-  normal m'
   setcursorcharpos(range.start.line + 1, range.start.character + 1)
 enddef