Close #3433 - Only use noselect if set for automatic completion

This commit is contained in:
w0rp 2021-06-19 10:57:34 +01:00
parent 84a4a76aaf
commit e78519683e
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
3 changed files with 19 additions and 14 deletions

View File

@ -269,13 +269,19 @@ function! s:ReplaceCompletionOptions(source) abort
let b:ale_old_completeopt = &l:completeopt let b:ale_old_completeopt = &l:completeopt
endif endif
if &l:completeopt =~# 'preview' let l:opt_list = split(&l:completeopt, ',')
let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' " The menu and noinsert options must be set, or automatic completion
elseif &l:completeopt =~# 'popup' " will be annoying.
let &l:completeopt = 'menu,menuone,popup,noselect,noinsert' let l:new_opt_list = ['menu', 'menuone', 'noinsert']
else
let &l:completeopt = 'menu,menuone,noselect,noinsert' " Permit some other completion options, provided users have set them.
endif for l:opt in ['preview', 'popup', 'noselect']
if index(l:opt_list, l:opt) >= 0
call add(l:new_opt_list, l:opt)
endif
endfor
let &l:completeopt = join(l:new_opt_list, ',')
endif endif
endfunction endfunction

View File

@ -561,7 +561,6 @@ vimrc, and your issues should go away. >
set completeopt=menu,menuone,preview,noselect,noinsert set completeopt=menu,menuone,preview,noselect,noinsert
< <
Or alternatively, if you want to show documentation in popups: > Or alternatively, if you want to show documentation in popups: >
set completeopt=menu,menuone,popup,noselect,noinsert set completeopt=menu,menuone,popup,noselect,noinsert

View File

@ -172,7 +172,7 @@ Execute(ale#completion#Show() should remember the completeopt setting and replac
call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}])
AssertEqual 'menu', b:ale_old_completeopt AssertEqual 'menu', b:ale_old_completeopt
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt AssertEqual 'menu,menuone,noinsert', &l:completeopt
AssertEqual [], g:feedkeys_calls AssertEqual [], g:feedkeys_calls
sleep 1ms sleep 1ms
@ -185,7 +185,7 @@ Execute(ale#completion#Show() should set the preview option if it's set):
call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}]) call ale#completion#Show([{'word': 'x', 'kind': 'v', 'icase': 1}])
AssertEqual 'menu,preview', b:ale_old_completeopt AssertEqual 'menu,preview', b:ale_old_completeopt
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt AssertEqual 'menu,menuone,noinsert,preview', &l:completeopt
AssertEqual [], g:feedkeys_calls AssertEqual [], g:feedkeys_calls
sleep 1ms sleep 1ms
@ -205,13 +205,13 @@ Execute(ale#completion#Show() should not replace the completeopt setting for man
AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls
Execute(ale#completion#AutomaticOmniFunc() should also remember the completeopt setting and replace it): Execute(ale#completion#AutomaticOmniFunc() should also remember the completeopt setting and replace it):
let &l:completeopt = 'menu' let &l:completeopt = 'menu,noselect'
let b:ale_completion_info = {'source': 'ale-automatic'} let b:ale_completion_info = {'source': 'ale-automatic'}
call ale#completion#AutomaticOmniFunc(0, '') call ale#completion#AutomaticOmniFunc(0, '')
AssertEqual 'menu', b:ale_old_completeopt AssertEqual 'menu,noselect', b:ale_old_completeopt
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt AssertEqual 'menu,menuone,noinsert,noselect', &l:completeopt
Execute(ale#completion#AutomaticOmniFunc() should set the preview option if it's set): Execute(ale#completion#AutomaticOmniFunc() should set the preview option if it's set):
let &l:completeopt = 'menu,preview' let &l:completeopt = 'menu,preview'
@ -220,7 +220,7 @@ Execute(ale#completion#AutomaticOmniFunc() should set the preview option if it's
call ale#completion#AutomaticOmniFunc(0, '') call ale#completion#AutomaticOmniFunc(0, '')
AssertEqual 'menu,preview', b:ale_old_completeopt AssertEqual 'menu,preview', b:ale_old_completeopt
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt AssertEqual 'menu,menuone,noinsert,preview', &l:completeopt
Execute(ale#completion#Show() should make the correct feedkeys() call for automatic completion): Execute(ale#completion#Show() should make the correct feedkeys() call for automatic completion):
let b:ale_completion_info = {'source': 'ale-automatic'} let b:ale_completion_info = {'source': 'ale-automatic'}