From f5a27a314a07591fed23bfd5ed808a2fc2246c53 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Fri, 20 Sep 2024 18:10:47 -0700 Subject: [PATCH] Ignore the select callback in an empty document symbol popup window --- autoload/lsp/symbol.vim | 2 +- test/clangd_tests.vim | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/autoload/lsp/symbol.vim b/autoload/lsp/symbol.vim index bcd547a..c64e6e6 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -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 diff --git a/test/clangd_tests.vim b/test/clangd_tests.vim index b084e86..dc3eeee 100644 --- a/test/clangd_tests.vim +++ b/test/clangd_tests.vim @@ -1548,8 +1548,11 @@ def g:Test_OmniComplete_AfterParen() redraw! cursor(4, 1) + var save_completeopt = &completeopt + set completeopt+=noselect,noinsert feedkeys("A\\\", '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 =<< trim END + void DocSymFunc1(void) + { + } + END + setline(1, lines) + g:WaitForServerFileLoad(0) + redraw! + + v:errmsg = '' + :LspDocumentSymbol + sleep 50m + feedkeys("x\", '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 -- 2.48.1