Skip to content

Commit 8b48c4e

Browse files
committed
feat: bugfix for filter api
1 parent 9eadfde commit 8b48c4e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

autoload/easycomplete/action/completion.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function! s:GetLspCompletionResult(server_name, data, plugin_name, word) abort
6767
let l:response = a:data['response']
6868

6969
" 这里包含了 info document 和 matches
70-
let g:xx = reltime()
7170
" 192 个元素
7271
" vim 用时 55 ms
7372
" lua 用时 29 ms
@@ -76,18 +75,21 @@ function! s:GetLspCompletionResult(server_name, data, plugin_name, word) abort
7675
else
7776
let l:completion_result = easycomplete#util#GetVimCompletionItems(l:response, a:plugin_name, a:word)
7877
endif
79-
" call s:console('<--', 'TODOTODOTODO', reltimestr(reltime(g:xx)), len(l:completion_result['items']))
8078
return {'matches': l:completion_result['items'], 'incomplete': l:completion_result['incomplete'] }
8179
endfunction
8280

8381
function! s:MatchResultFilterPipe(plugin_name, matches, ctx)
8482
let lsp_ctx = easycomplete#GetCurrentLspContext()
85-
if type(get(lsp_ctx, "constructor")) != type('')
86-
let fn_name = a:plugin_name
87-
let Fun_name = "easycomplete#sources#" . fn_name . "#filter"
83+
if has_key(lsp_ctx, "filter")
84+
let Fun_name = lsp_ctx["filter"]
8885
else
89-
let constructor_str = lsp_ctx["constructor"]
90-
let Fun_name = substitute(constructor_str, "#constructor$", "#filter", "g")
86+
if type(get(lsp_ctx, "constructor")) != type('')
87+
let fn_name = a:plugin_name
88+
let Fun_name = "easycomplete#sources#" . fn_name . "#filter"
89+
else
90+
let constructor_str = lsp_ctx["constructor"]
91+
let Fun_name = substitute(constructor_str, "#constructor$", "#filter", "g")
92+
endif
9193
endif
9294
if !easycomplete#util#FuncExists(Fun_name)
9395
return a:matches

0 commit comments

Comments
 (0)