diff options
-rw-r--r-- | autoload/ale/completion.vim | 6 | ||||
-rw-r--r-- | test/completion/test_completion_events.vader | 19 |
2 files changed, 23 insertions, 2 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 4823b00c..694cb655 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -134,7 +134,11 @@ function! s:ReplaceCompleteopt() abort let b:ale_old_completopt = &l:completeopt endif - let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' + 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 diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index fbe18bb6..96182013 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -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() |