From aa3777fa2317eedbad00d2b9df73864be7099d87 Mon Sep 17 00:00:00 2001 From: Girish Palya Date: Thu, 1 Feb 2024 19:36:19 +0100 Subject: [PATCH] Correctly handle keys inside symbol popup window Symbol popup window handles following keys: - and to advance selection - selection wraps around at end - and scroll popup instead of main window M autoload/lsp/symbol.vim --- autoload/lsp/symbol.vim | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/autoload/lsp/symbol.vim b/autoload/lsp/symbol.vim index 7d26df8..5716454 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -802,7 +802,7 @@ enddef # Key filter function for the symbol popup menu. def SymbolMenuFilterKey(symPopupMenu: number, key: string): bool - var keyHandled = false + var keyHandled = true var updateInputPopup = false var inputText = symPopupMenu->getwinvar('inputText', '') var symInputPopup = symPopupMenu->getwinvar('symbolInputPopup', 0) @@ -811,33 +811,48 @@ def SymbolMenuFilterKey(symPopupMenu: number, # Erase a character in the input popup if inputText->len() >= 1 inputText = inputText[: -2] - keyHandled = true updateInputPopup = true + else + keyHandled = false endif elseif key == "\" # Erase all the characters in the input popup inputText = '' - keyHandled = true updateInputPopup = true + elseif key == "\" + || key == "\" + || key == "\" + || key == "\" + var ln = getcurpos(symPopupMenu)[1] + win_execute(symPopupMenu, "normal! j") + if ln == getcurpos(symPopupMenu)[1] + win_execute(symPopupMenu, "normal! gg") + endif + elseif key == "\" + || key == "\" + || key == "\" + || key == "\" + var ln = getcurpos(symPopupMenu)[1] + win_execute(symPopupMenu, "normal! k") + if ln == getcurpos(symPopupMenu)[1] + win_execute(symPopupMenu, "normal! G") + endif + elseif key == "\" + win_execute(symPopupMenu, 'normal! ' .. "\") + elseif key == "\" + win_execute(symPopupMenu, 'normal! ' .. "\") elseif key == "\" || key == "\" - || key == "\" - || key == "\" || key == "\" || key == "\" - || key == "\" - || key == "\" - # scroll the symbol popup window - var cmd: string = 'normal! ' .. (key == "\" ? 'j' : - key == "\" ? 'k' : key) - win_execute(symPopupMenu, cmd) - keyHandled = true + win_execute(symPopupMenu, $"normal! {key}") elseif key =~ '^\k$' # A keyword character is typed. Add to the input text and update the # popup inputText ..= key - keyHandled = true updateInputPopup = true + else + keyHandled = false endif var symTblFiltered: list> = [] -- 2.48.1