diff options
author | w0rp <devw0rp@gmail.com> | 2019-03-08 21:32:05 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-03-08 21:32:05 +0000 |
commit | 413529f603547bad184358db06f8388047a5c9aa (patch) | |
tree | c31cdb07b568077bcbc11c8c7fad81d2699a60db /test/completion/test_completion_events.vader | |
parent | be2c0c3af5e9685b3e1235fa062cb148d740e830 (diff) | |
download | ale-413529f603547bad184358db06f8388047a5c9aa.zip |
Fix #2326 - ALEComplete no longer replaces completeopt
Diffstat (limited to 'test/completion/test_completion_events.vader')
-rw-r--r-- | test/completion/test_completion_events.vader | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index 3f0bfa70..d04a8085 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -27,7 +27,7 @@ Before: let g:get_completions_called = 0 " We just want to check if the function is called. - function! ale#completion#GetCompletions() + function! ale#completion#GetCompletions(manual) let g:get_completions_called = 1 endfunction @@ -53,7 +53,7 @@ After: unlet! g:fake_mode unlet! g:get_completions_called unlet! b:ale_old_omnifunc - unlet! b:ale_old_completopt + unlet! b:ale_old_completeopt unlet! b:ale_completion_info unlet! b:ale_completion_response unlet! b:ale_completion_parser @@ -86,7 +86,7 @@ Execute(ale#completion#GetCompletions should not be called when the cursor posit call setpos('.', [bufnr(''), 1, 2, 0]) " We just want to check if the function is called. - function! ale#completion#GetCompletions() + function! ale#completion#GetCompletions(manual) let g:get_completions_called = 1 endfunction @@ -105,7 +105,7 @@ Execute(ale#completion#GetCompletions should not be called if you switch to norm let g:fake_mode = 'n' " We just want to check if the function is called. - function! ale#completion#GetCompletions() + function! ale#completion#GetCompletions(manual) let g:get_completions_called = 1 endfunction @@ -138,7 +138,7 @@ 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', b:ale_old_completeopt AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt AssertEqual [], g:feedkeys_calls @@ -150,19 +150,32 @@ Execute(ale#completion#Show() should set the preview option if it's set): call ale#completion#Show('Response', 'Parser') - AssertEqual 'menu,preview', b:ale_old_completopt + AssertEqual 'menu,preview', b:ale_old_completeopt AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt AssertEqual [], g:feedkeys_calls sleep 1ms AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls +Execute(ale#completion#Show() should not replace the completeopt setting for manual completion): + let b:ale_completion_info = {'manual': 1} + + let &l:completeopt = 'menu,preview' + + call ale#completion#Show('Response', 'Parser') + + Assert !exists('b:ale_old_completeopt') + + AssertEqual [], g:feedkeys_calls + sleep 1ms + AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls + Execute(ale#completion#OmniFunc() should also remember the completeopt setting and replace it): let &l:completeopt = 'menu' call ale#completion#OmniFunc(0, '') - AssertEqual 'menu', b:ale_old_completopt + AssertEqual 'menu', b:ale_old_completeopt AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt Execute(ale#completion#OmniFunc() should set the preview option if it's set): @@ -170,7 +183,7 @@ Execute(ale#completion#OmniFunc() should set the preview option if it's set): call ale#completion#OmniFunc(0, '') - AssertEqual 'menu,preview', b:ale_old_completopt + AssertEqual 'menu,preview', b:ale_old_completeopt AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt Execute(ale#completion#Show() should make the correct feedkeys() call): @@ -188,7 +201,7 @@ Execute(ale#completion#Show() shouldn't do anything if you switch back to normal AssertEqual 'menu,preview', &l:completeopt Assert !exists('b:ale_old_omnifunc') - Assert !exists('b:ale_old_completopt') + Assert !exists('b:ale_old_completeopt') Assert !exists('b:ale_completion_response') Assert !exists('b:ale_completion_parser') AssertEqual [], g:feedkeys_calls @@ -209,12 +222,12 @@ Execute(ale#completion#Done() should restore old omnifunc values): Assert !has_key(b:, 'ale_old_omnifunc') Execute(ale#completion#Done() should restore the old completeopt setting): - let b:ale_old_completopt = 'menu' + let b:ale_old_completeopt = 'menu' call ale#completion#Done() AssertEqual 'menu', &l:completeopt - Assert !has_key(b:, 'ale_old_completopt') + Assert !has_key(b:, 'ale_old_completeopt') Execute(ale#completion#Done() should leave settings alone when none were remembered): let &l:omnifunc = 'BazBoz' @@ -236,7 +249,23 @@ Execute(The completion request_id should be reset when queuing again): Execute(b:ale_completion_info should be set up correctly when requesting completions): call setpos('.', [bufnr(''), 3, 14, 0]) - call ale#completion#GetCompletions() + call ale#completion#GetCompletions(0) + + AssertEqual + \ { + \ 'request_id': 0, + \ 'conn_id': 0, + \ 'column': 14, + \ 'line_length': 14, + \ 'line': 3, + \ 'prefix': 'ab', + \ 'manual': 0, + \ }, + \ b:ale_completion_info + +Execute(b:ale_completion_info should be set up correctly when requesting completions): + call setpos('.', [bufnr(''), 3, 14, 0]) + ALEComplete AssertEqual \ { @@ -246,6 +275,7 @@ Execute(b:ale_completion_info should be set up correctly when requesting complet \ 'line_length': 14, \ 'line': 3, \ 'prefix': 'ab', + \ 'manual': 1, \ }, \ b:ale_completion_info @@ -264,7 +294,7 @@ Execute(The correct keybinds should be configured): Execute(Running the normal mode <Plug> keybind should reset the settings): let b:ale_old_omnifunc = 'FooBar' - let b:ale_old_completopt = 'menu' + let b:ale_old_completeopt = 'menu' " We can't run the keybind, but we can call the function. call ale#completion#RestoreCompletionOptions() @@ -272,4 +302,4 @@ Execute(Running the normal mode <Plug> keybind should reset the settings): AssertEqual 'FooBar', &l:omnifunc AssertEqual 'menu', &l:completeopt Assert !has_key(b:, 'ale_old_omnifunc') - Assert !has_key(b:, 'ale_old_completopt') + Assert !has_key(b:, 'ale_old_completeopt') |