Close #1690 - Respect the preview setting for completeopt

This commit is contained in:
w0rp 2018-07-04 08:52:08 +01:00
parent db85b931ec
commit ca7fa31c61
No known key found for this signature in database
GPG key ID: 0FC1ECAA8C81CD83
2 changed files with 23 additions and 2 deletions

View file

@ -134,7 +134,11 @@ function! s:ReplaceCompleteopt() abort
let b:ale_old_completopt = &l:completeopt
endif
if &l:completeopt =~# 'preview'
let &l:completeopt = 'menu,menuone,preview,noselect,noinsert'
else
let &l:completeopt = 'menu,menuone,noselect,noinsert'
endif
endfunction
function! ale#completion#OmniFunc(findstart, base) abort

View file

@ -9,6 +9,8 @@ Before:
let g:get_completions_called = 0
let g:feedkeys_calls = []
let &l:completeopt = 'menu,menuone,preview,noselect,noinsert'
runtime autoload/ale/util.vim
function! ale#util#FeedKeys(string, mode) abort
@ -95,6 +97,14 @@ Execute(ale#completion#Show() should remember the completeopt setting and replac
call ale#completion#Show('Response', 'Parser')
AssertEqual 'menu', b:ale_old_completopt
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt
Execute(ale#completion#Show() should set the preview option if it's set):
let &l:completeopt = 'menu,preview'
call ale#completion#Show('Response', 'Parser')
AssertEqual 'menu,preview', b:ale_old_completopt
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt
Execute(ale#completion#OmniFunc() should also remember the completeopt setting and replace it):
@ -103,6 +113,14 @@ Execute(ale#completion#OmniFunc() should also remember the completeopt setting a
call ale#completion#OmniFunc(0, '')
AssertEqual 'menu', b:ale_old_completopt
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt
Execute(ale#completion#OmniFunc() should set the preview option if it's set):
let &l:completeopt = 'menu,preview'
call ale#completion#OmniFunc(0, '')
AssertEqual 'menu,preview', b:ale_old_completopt
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt
Execute(ale#completion#Show() should make the correct feedkeys() call):
@ -127,7 +145,6 @@ Execute(ale#completion#Done() should restore old omnifunc values):
Execute(ale#completion#Done() should restore the old completeopt setting):
let b:ale_old_completopt = 'menu'
let &l:completeopt = 'menu,menuone,preview,noselect,noinsert'
call ale#completion#Done()