From 7640af01366c5419a0e18dec07a399b28efee8c7 Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Sun, 19 Mar 2023 19:29:50 +0100 Subject: [PATCH] Don't add two entries to the jump list when jumping to a symbol in another file --- autoload/lsp/util.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index 0e18dcf..9343d4e 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -172,7 +172,11 @@ export def JumpToLspLocation(location: dict, 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, 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 -- 2.48.1