mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 13:34:46 +08:00
Manually trigger autocomplete even when prefix is ""
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user