]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
When jumping to a symbol definition, reuse the current window if 'hidden' is set
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 8 Mar 2022 18:56:05 +0000 (10:56 -0800)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 8 Mar 2022 18:56:05 +0000 (10:56 -0800)
autoload/lsp/symbol.vim
doc/lsp.txt

index 66b1ea5e3520e0e4c9befb310041b1556b3f05ad..f61d65065eed38f00a9cb45e6eddf8340e4192d4 100644 (file)
@@ -264,15 +264,19 @@ export def GotoSymbol(lspserver: dict<any>, location: dict<any>, type: string)
     else
       var bnr: number = fname->bufnr()
       if bnr != -1
-        if &modified || &buftype != ''
+       # Reuse an existing buffer. If the current buffer has unsaved changes
+       # and 'hidden' is not set or if the current buffer is a special
+       # buffer, then open the buffer in a new window.
+        if (&modified && !&hidden) || &buftype != ''
           exe 'sbuffer ' .. bnr
         else
           exe 'buf ' .. bnr
         endif
       else
-        if &modified || &buftype != ''
-          # if the current buffer has unsaved changes, then open the file in a
-          # new window
+        if (&modified && !&hidden) || &buftype != ''
+         # if the current buffer has unsaved changes and 'hidden' is not set,
+         # or if the current buffer is a special buffer, then open the file
+         # in a new window
           exe 'split ' .. fname
         else
           exe 'edit  ' .. fname
index f463686d4d96370396b7814360f5d847dfae87b2..93ed7ccc3996c26b0f2d04ae7d74230807a535bd 100644 (file)
@@ -2,7 +2,7 @@
 
 Author: Yegappan Lakshmanan  (yegappan AT yahoo DOT com)
 For Vim version 8.2.2342 and above
-Last change: Feb 17, 2022
+Last change: Mar 8, 2022
 
 ==============================================================================
                                                *lsp-license*
@@ -244,12 +244,15 @@ diagnostic messages, you can add the following line to your .vimrc file:
 
                                                *:LspGotoDefinition*
 :LspGotoDefinition     Jumps to the definition of the symbol under the
-                       cursor. If the file is already present in a window,
-                       then jumps to that window. Otherwise, opens the file
-                       in a  new window. If the jump is successful, then the
-                       current cursor location is pushed onto the tag stack.
-                       Also the |``| mark is set to the position before the
-                       jump.
+                       cursor.  If the file is already present in a window,
+                       then jumps to that window.  Otherwise, opens the file
+                       in a  new window.  If the current buffer is modified
+                       and 'hidden' is not set or if the current buffer is a
+                       special buffer, then a new window is opened.  If the
+                       jump is successful, then the current cursor location
+                       is pushed onto the tag stack.  The |CTRL-T| command
+                       can be used to go back up the tag stack.  Also the
+                       |``| mark is set to the position before the jump.
 
                                                *:LspGotoDeclaration*
 :LspGotoDeclaration    Jumps to the declaration of the symbol under the