Skip to content

Commit

Permalink
Ignore the select callback in an empty document symbol popup window
Browse files Browse the repository at this point in the history
  • Loading branch information
yegappan committed Sep 21, 2024
1 parent 8a67f5a commit f5a27a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/lsp/symbol.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions test/clangd_tests.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f5a27a3

Please sign in to comment.