From: shane.xb.qian Date: Sun, 31 Dec 2023 06:18:58 +0000 (+0800) Subject: none: refine code action regex a bit X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4be66ebb4c8683204d0be870255c1598902dd80e;p=vim-lsp.git none: refine code action regex a bit Signed-off-by: shane.xb.qian --- diff --git a/autoload/lsp/codeaction.vim b/autoload/lsp/codeaction.vim index 9aa9c9a..fb2a91a 100644 --- a/autoload/lsp/codeaction.vim +++ b/autoload/lsp/codeaction.vim @@ -82,12 +82,13 @@ export def ApplyCodeAction(lspserver: dict, actionlist: list>, qu var choice: number - if query =~ '^\d\+' # digit - choice = query->str2nr() - elseif query =~ '^/' # regex - choice = 1 + util.Indexof(actions, (i, a) => a.title =~ query[1 : ]) - elseif query != '' # literal string - choice = 1 + util.Indexof(actions, (i, a) => a.title[0 : query->len() - 1] == query) + var query_ = query->trim() + if query_ =~ '^\d\+$' # digit + choice = query_->str2nr() + elseif query_ =~ '^/' # regex + choice = 1 + util.Indexof(actions, (i, a) => a.title =~ query_[1 : ]) + elseif query_ != '' # literal string + choice = 1 + util.Indexof(actions, (i, a) => a.title[0 : query_->len() - 1] == query_) elseif opt.lspOptions.usePopupInCodeAction # Use a popup menu to show the code action popup_create(text, {