]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Ignore the select callback in an empty document symbol popup window
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 21 Sep 2024 01:10:47 +0000 (18:10 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 21 Sep 2024 01:10:47 +0000 (18:10 -0700)
autoload/lsp/symbol.vim
test/clangd_tests.vim

index bcd547a33200419de42352aa6e27c427aa5b1d16..c64e6e64bc5dd1e9cef86c039325ede2fb99453b 100644 (file)
@@ -777,7 +777,7 @@ def SymbolMenuItemSelected(symPopupMenu: number,
   # Restore the cursor to the location where the command was invoked
   setpos('.', save_curpos)
 
-  if result > 0
+  if result > 0 && symTblFiltered->len() > 0
     # A symbol is selected in the popup menu
 
     # Set the previous cursor location mark. Instead of using setpos(), m' is
index b084e8618728056f79378e1caf0f7d9ae06500a5..dc3eeee8a7ca2603f0555573f7ad07806e0710b2 100644 (file)
@@ -1548,8 +1548,11 @@ def g:Test_OmniComplete_AfterParen()
   redraw!
 
   cursor(4, 1)
+  var save_completeopt = &completeopt
+  set completeopt+=noselect,noinsert
   feedkeys("A\<C-X>\<C-O>\<C-Y>", 'xt')
   assert_equal('  printf(', getline('.'))
+  &completeopt = save_completeopt
   :%bw!
 enddef
 
@@ -1765,6 +1768,28 @@ def g:Test_DiagSigns()
   :%bw!
 enddef
 
+def g:Test_DocumentSymbol()
+  :silent! edit Xdocsymbol.c
+  sleep 200m
+  var lines: list<string> =<< trim END
+    void DocSymFunc1(void)
+    {
+    }
+  END
+  setline(1, lines)
+  g:WaitForServerFileLoad(0)
+  redraw!
+
+  v:errmsg = ''
+  :LspDocumentSymbol
+  sleep 50m
+  feedkeys("x\<CR>", 'xt')
+  popup_clear()
+  assert_equal('', v:errmsg)
+
+  :%bw!
+enddef
+
 # TODO:
 # 1. Add a test for autocompletion with a single match while ignoring case.
 #    After the full matched name is typed, the completion popup should still