diff options
author | Famiu Haque <famiuhaque@protonmail.com> | 2024-05-24 15:57:46 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 11:57:46 +0200 |
commit | a616272f568a9492580abfd22ab460457ecdbfa3 (patch) | |
tree | 54d644a7045c54ada00c64945fa2327330b14ccb /test | |
parent | d123202ae6ef3f046d5b6579c194dca82ddb8a8f (diff) | |
download | rneovim-a616272f568a9492580abfd22ab460457ecdbfa3.tar.gz rneovim-a616272f568a9492580abfd22ab460457ecdbfa3.tar.bz2 rneovim-a616272f568a9492580abfd22ab460457ecdbfa3.zip |
feat(complete): specify reason for CompleteDone
Problem: `CompleteDone` currently does not specify the reason for why completion was done, which is problematic for completion plugins as they cannot know whether the event was triggered due to the completion being canceled, accepted, or for some other reason.
Solution: Add a `reason` key to `v:event`, which is set by `CompleteDone` to indicate why completion ended.
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/autocmd/completedone_spec.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/functional/autocmd/completedone_spec.lua b/test/functional/autocmd/completedone_spec.lua new file mode 100644 index 0000000000..33beb16db2 --- /dev/null +++ b/test/functional/autocmd/completedone_spec.lua @@ -0,0 +1,41 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command +local call = n.call +local feed = n.feed +local eval = n.eval +local eq = t.eq + +describe('CompleteDone', function() + before_each(clear) + + describe('sets v:event.reason', function() + before_each(function() + clear() + command('autocmd CompleteDone * let g:donereason = v:event.reason') + feed('i') + call('complete', call('col', '.'), { 'foo', 'bar' }) + end) + + it('accept', function() + feed('<C-y>') + eq('accept', eval('g:donereason')) + end) + describe('cancel', function() + it('on <C-e>', function() + feed('<C-e>') + eq('cancel', eval('g:donereason')) + end) + it('on non-keyword character', function() + feed('<Esc>') + eq('cancel', eval('g:donereason')) + end) + it('when overriden by another complete()', function() + call('complete', call('col', '.'), { 'bar', 'baz' }) + eq('cancel', eval('g:donereason')) + end) + end) + end) +end) |