mirror of
https://github.com/neovim/neovim.git
synced 2026-05-01 11:34:56 +00:00
autocmd: add MenuPopupChanged autocmd
Update src/nvim/auevents.lua Co-Authored-By: chemzqm <chemzqm@gmail.com>
This commit is contained in:
@@ -1072,4 +1072,83 @@ describe('completion', function()
|
||||
set complete&vim completeopt&vim
|
||||
]])
|
||||
end)
|
||||
|
||||
it('MenuPopupChanged autocommand', function()
|
||||
curbufmeths.set_lines(0, 1, false, { 'foo', 'bar', 'foobar', ''})
|
||||
source([[
|
||||
set complete=. completeopt=noinsert,noselect,menuone
|
||||
function! OnPumChange()
|
||||
let g:event = copy(v:event)
|
||||
let g:item = get(v:event, 'completed_item', {})
|
||||
let g:word = get(g:item, 'word', v:null)
|
||||
endfunction
|
||||
autocmd! MenuPopupChanged * :call OnPumChange()
|
||||
call cursor(4, 1)
|
||||
]])
|
||||
|
||||
feed('Sf<C-N>')
|
||||
screen:expect([[
|
||||
foo |
|
||||
bar |
|
||||
foobar |
|
||||
f^ |
|
||||
{1:foo }{0: }|
|
||||
{1:foobar }{0: }|
|
||||
{0:~ }|
|
||||
{3:-- Keyword completion (^N^P) }{5:Back at original} |
|
||||
]])
|
||||
eq({completed_item = {}, width = 15,
|
||||
height = 2, size = 2,
|
||||
col = 0, row = 4, scrollbar = false},
|
||||
eval('g:event'))
|
||||
feed('<C-N>')
|
||||
screen:expect([[
|
||||
foo |
|
||||
bar |
|
||||
foobar |
|
||||
foo^ |
|
||||
{2:foo }{0: }|
|
||||
{1:foobar }{0: }|
|
||||
{0:~ }|
|
||||
{3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
|
||||
]])
|
||||
eq('foo', eval('g:word'))
|
||||
feed('<C-N>')
|
||||
screen:expect([[
|
||||
foo |
|
||||
bar |
|
||||
foobar |
|
||||
foobar^ |
|
||||
{1:foo }{0: }|
|
||||
{2:foobar }{0: }|
|
||||
{0:~ }|
|
||||
{3:-- Keyword completion (^N^P) }{4:match 2 of 2} |
|
||||
]])
|
||||
eq('foobar', eval('g:word'))
|
||||
feed('<up>')
|
||||
screen:expect([[
|
||||
foo |
|
||||
bar |
|
||||
foobar |
|
||||
foobar^ |
|
||||
{2:foo }{0: }|
|
||||
{1:foobar }{0: }|
|
||||
{0:~ }|
|
||||
{3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
|
||||
]])
|
||||
eq('foo', eval('g:word'))
|
||||
feed('<down>')
|
||||
screen:expect([[
|
||||
foo |
|
||||
bar |
|
||||
foobar |
|
||||
foobar^ |
|
||||
{1:foo }{0: }|
|
||||
{2:foobar }{0: }|
|
||||
{0:~ }|
|
||||
{3:-- Keyword completion (^N^P) }{4:match 2 of 2} |
|
||||
]])
|
||||
eq('foobar', eval('g:word'))
|
||||
feed('<esc>')
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user