From 4be66ebb4c8683204d0be870255c1598902dd80e Mon Sep 17 00:00:00 2001 From: "shane.xb.qian" Date: Sun, 31 Dec 2023 14:18:58 +0800 Subject: [PATCH] none: refine code action regex a bit Signed-off-by: shane.xb.qian --- autoload/lsp/codeaction.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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, { -- 2.48.1