From 021c5875c13e0c4a5bab67e2e2ac50c4be653ad6 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 11 Feb 2018 22:37:14 +0900 Subject: vim-patch:8.0.1494: no autocmd triggered in Insert mode with visible popup menu Problem: No autocmd triggered in Insert mode with visible popup menu. Solution: Add TextChangedP. (Prabir Shrestha, Christian Brabandt, closes vim/vim#2372, closes vim/vim#1691) Fix that the TextChanged autocommands are not always triggered when sourcing a script. https://github.com/vim/vim/commit/5a093437199001a0d60d8e18e2b9539b99a7757c --- test/functional/viml/completion_spec.lua | 90 ++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'test') diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index 216ccb3744..93d3909568 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -3,7 +3,10 @@ local Screen = require('test.functional.ui.screen') local clear, feed = helpers.clear, helpers.feed local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq local feed_command, source, expect = helpers.feed_command, helpers.source, helpers.expect +local curbufmeths = helpers.curbufmeths +local command = helpers.command local meths = helpers.meths +local wait = helpers.wait describe('completion', function() local screen @@ -971,4 +974,91 @@ describe('ui/ext_popupmenu', function() eq(nil, items) -- popupmenu was hidden end) end) + + describe('TextChangeP autocommand', function() + it('can trigger TextChangedP autocommand as expected', + function() + curbufmeths.set_lines(0, 1, false, { 'foo', 'bar', 'foobar'}) + command('set complete=. completeopt=menuone') + command('let g:foo = []') + command('autocmd! TextChanged * :call add(g:foo, "N")') + command('autocmd! TextChangedI * :call add(g:foo, "I")') + command('autocmd! TextChangedP * :call add(g:foo, "P")') + command('call cursor(3, 1)') + + command('let g:foo = []') + feed('o') + wait() + feed('') + assert.same({'I'}, eval('g:foo')) + + command('let g:foo = []') + feed('S') + wait() + feed('f') + wait() + assert.same({'I', 'I'}, eval('g:foo')) + feed('') + + command('let g:foo = []') + feed('S') + wait() + feed('f') + wait() + feed('') + wait() + assert.same({'I', 'I', 'P'}, eval('g:foo')) + feed('') + + command('let g:foo = []') + feed('S') + wait() + feed('f') + wait() + feed('') + wait() + feed('') + wait() + assert.same({'I', 'I', 'P', 'P'}, eval('g:foo')) + feed('') + + command('let g:foo = []') + feed('S') + wait() + feed('f') + wait() + feed('') + wait() + feed('') + wait() + feed('') + wait() + assert.same({'I', 'I', 'P', 'P', 'P'}, eval('g:foo')) + feed('') + + command('let g:foo = []') + feed('S') + wait() + feed('f') + wait() + feed('') + wait() + feed('') + wait() + feed('') + wait() + feed('') + assert.same({'I', 'I', 'P', 'P', 'P', 'P'}, eval('g:foo')) + feed('') + + assert.same({'foo', 'bar', 'foobar', 'foo'}, eval('getline(1, "$")')) + + source([[ + au! TextChanged + au! TextChangedI + au! TextChangedP + set complete&vim completeopt&vim + ]]) + end) + end) end) -- cgit