Manually trigger autocomplete even when prefix is ""

This commit is contained in:
Jerko Steiner
2019-01-07 23:23:33 +01:00
parent 0fcd5e79a9
commit 9bcf8a2336
2 changed files with 8 additions and 4 deletions

View File

@@ -106,7 +106,7 @@ function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort
" foo. " foo.
" ^ " ^
" We need to include all of the given suggestions. " We need to include all of the given suggestions.
if index(l:triggers, a:prefix) >= 0 if index(l:triggers, a:prefix) >= 0 || empty(a:prefix)
let l:filtered_suggestions = a:suggestions let l:filtered_suggestions = a:suggestions
else else
let l:filtered_suggestions = [] let l:filtered_suggestions = []
@@ -509,17 +509,18 @@ function! ale#completion#GetCompletions() abort
return return
endif endif
call ale#completion#AlwaysGetCompletions() call ale#completion#AlwaysGetCompletions(1)
endfunction endfunction
" This function can be used to manually trigger autocomplete, even when " This function can be used to manually trigger autocomplete, even when
" g:ale_completion_enabled is set to false " g:ale_completion_enabled is set to false
function! ale#completion#AlwaysGetCompletions() abort function! ale#completion#AlwaysGetCompletions(...) abort
let l:need_prefix = get(a:, 1, 0)
let [l:line, l:column] = getcurpos()[1:2] let [l:line, l:column] = getcurpos()[1:2]
let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column)
if empty(l:prefix) if l:need_prefix && empty(l:prefix)
return return
endif endif

View File

@@ -16,6 +16,9 @@ Execute(Prefix filtering should work for Lists of strings):
AssertEqual AssertEqual
\ ['FooBar', 'FongBar', 'baz', 'foo'], \ ['FooBar', 'FongBar', 'baz', 'foo'],
\ ale#completion#Filter(bufnr(''), '', ['FooBar', 'FongBar', 'baz', 'foo'], '.') \ ale#completion#Filter(bufnr(''), '', ['FooBar', 'FongBar', 'baz', 'foo'], '.')
AssertEqual
\ ['FooBar', 'FongBar', 'baz', 'foo'],
\ ale#completion#Filter(bufnr(''), '', ['FooBar', 'FongBar', 'baz', 'foo'], '')
Execute(Prefix filtering should work for completion items): Execute(Prefix filtering should work for completion items):
AssertEqual AssertEqual