diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/autocmd_spec.lua | 51 | ||||
-rw-r--r-- | test/old/testdir/gen_opt_test.vim | 2 | ||||
-rw-r--r-- | test/old/testdir/test_autocmd.vim | 60 | ||||
-rw-r--r-- | test/old/testdir/test_options.vim | 2 |
4 files changed, 115 insertions, 0 deletions
diff --git a/test/functional/legacy/autocmd_spec.lua b/test/functional/legacy/autocmd_spec.lua index 4d82da6312..1071776b68 100644 --- a/test/functional/legacy/autocmd_spec.lua +++ b/test/functional/legacy/autocmd_spec.lua @@ -1,5 +1,6 @@ local t = require('test.testutil') local n = require('test.functional.testnvim')() +local Screen = require('test.functional.ui.screen') local clear = n.clear local write_file = t.write_file @@ -40,3 +41,53 @@ it('no E440 in quickfix window when autocommand invalidates undo', function() feed('G') eq('', api.nvim_get_vvar('errmsg')) end) + +-- oldtest: Test_WinScrolled_Resized_eiw() +it('WinScrolled and WinResized events can be ignored in a window', function() + local screen = Screen.new() + n.exec([[ + call setline(1, ['foo']->repeat(32)) + set eventignorewin=WinScrolled,WinResized + split + let [g:afile,g:resized,g:scrolled] = ['none',0,0] + au WinScrolled * let [g:afile,g:scrolled] = [expand('<afile>'),g:scrolled+1] + au WinResized * let [g:afile,g:resized] = [expand('<afile>'),g:resized+1] + ]]) + feed('<C-W>-') + screen:expect([[ + ^foo | + foo |*4 + {3:[No Name] [+] }| + foo |*6 + {2:[No Name] [+] }| + | + ]]) + feed(':echo g:afile g:resized g:scrolled<CR>') + screen:expect({ any = 'none 0 0.*' }) + feed('G') + screen:expect([[ + foo |*4 + ^foo | + {3:[No Name] [+] }| + foo |*6 + {2:[No Name] [+] }| + none 0 0 | + ]]) + feed('gg') + screen:expect([[ + ^foo | + foo |*4 + {3:[No Name] [+] }| + foo |*6 + {2:[No Name] [+] }| + none 0 0 | + ]]) + feed(':echo g:afile g:resized g:scrolled') + screen:expect({ any = ':echo g:afile g:resized g:scrolled.*' }) + feed('<CR>') + screen:expect({ any = 'none 0 0.*' }) + feed(':set eventignorewin=<CR><C-W>w<C-W>+') + screen:expect({ any = ':set eventignorewin=.*' }) + feed(':echo win_getid() g:afile g:resized g:scrolled<CR>') + screen:expect({ any = '1000 1001 1 1.*' }) +end) diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim index f12ce8c7c4..64876ce318 100644 --- a/test/old/testdir/gen_opt_test.vim +++ b/test/old/testdir/gen_opt_test.vim @@ -220,6 +220,8 @@ let test_values = { "\ 'encoding': [['latin1'], ['xxx', '']], \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], \ ['xxx']], + \ 'eventignorewin': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], + \ ['xxx', 'WinNew']], \ 'fileencoding': [['', 'latin1', 'xxx'], []], \ 'fileformat': [['dos', 'unix', 'mac'], ['xxx']], \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']], diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index d5f7c928de..701b0a17a4 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -4205,4 +4205,64 @@ func Test_OptionSet_cmdheight() set cmdheight& mouse& laststatus& endfunc +func Test_eventignorewin() + defer CleanUpTestAuGroup() + augroup testing + au WinEnter * :call add(g:evs, ["WinEnter", expand("<afile>")]) + au WinLeave * :call add(g:evs, ["WinLeave", expand("<afile>")]) + au BufWinEnter * :call add(g:evs, ["BufWinEnter", expand("<afile>")]) + augroup END + + let g:evs = [] + set eventignorewin=WinLeave,WinEnter + split foo + call assert_equal([['BufWinEnter', 'foo']], g:evs) + set eventignorewin=all + edit bar + call assert_equal([['BufWinEnter', 'foo']], g:evs) + set eventignorewin= + wincmd w + call assert_equal([['BufWinEnter', 'foo'], ['WinLeave', 'bar']], g:evs) + + only! + %bwipe! + set eventignorewin& + unlet g:evs +endfunc + +func Test_WinScrolled_Resized_eiw() + CheckRunVimInTerminal + + let lines =<< trim END + call setline(1, ['foo']->repeat(32)) + set eventignorewin=WinScrolled,WinResized + split + let [g:afile,g:resized,g:scrolled] = ['none',0,0] + au WinScrolled * let [g:afile,g:scrolled] = [expand('<afile>'),g:scrolled+1] + au WinResized * let [g:afile,g:resized] = [expand('<afile>'),g:resized+1] + END + call writefile(lines, 'Xtest_winscrolled_eiw', 'D') + let buf = RunVimInTerminal('-S Xtest_winscrolled_eiw', {'rows': 10}) + + " Both windows are ignoring resize events + call term_sendkeys(buf, "\<C-W>-") + call TermWait(buf) + call term_sendkeys(buf, ":echo g:afile g:resized g:scrolled\<CR>") + call WaitForAssert({-> assert_equal('none 0 0', term_getline(buf, 10))}, 1000) + + " And scroll events + call term_sendkeys(buf, "Ggg") + call TermWait(buf) + call term_sendkeys(buf, ":echo g:afile g:resized g:scrolled\<CR>") + call WaitForAssert({-> assert_equal('none 0 0', term_getline(buf, 10))}, 1000) + + " Un-ignore events in second window, make first window current and resize + call term_sendkeys(buf, ":set eventignorewin=\<CR>\<C-W>w\<C-W>+") + call TermWait(buf) + call term_sendkeys(buf, ":echo win_getid() g:afile g:resized g:scrolled\<CR>") + call WaitForAssert({-> assert_equal('1000 1001 1 1', term_getline(buf, 10))}, 1000) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim index 2479f0ca51..ce2d9ba05a 100644 --- a/test/old/testdir/test_options.vim +++ b/test/old/testdir/test_options.vim @@ -589,6 +589,7 @@ func Test_set_completion_string_values() " Other string options that queries the system rather than fixed enum names call assert_equal(['all', 'BufAdd'], getcompletion('set eventignore=', 'cmdline')[0:1]) + call assert_equal(['WinLeave', 'WinResized', 'WinScrolled'], getcompletion('set eiw=', 'cmdline')[-3:-1]) call assert_equal('latin1', getcompletion('set fileencodings=', 'cmdline')[1]) " call assert_equal('top', getcompletion('set printoptions=', 'cmdline')[0]) " call assert_equal('SpecialKey', getcompletion('set wincolor=', 'cmdline')[0]) @@ -2506,6 +2507,7 @@ func Test_string_option_revert_on_failure() \ ['eadirection', 'hor', 'a123'], \ ['encoding', 'utf-8', 'a123'], \ ['eventignore', 'TextYankPost', 'a123'], + \ ['eventignorewin', 'WinScrolled', 'a123'], \ ['fileencoding', 'utf-8', 'a123,'], \ ['fileformat', 'mac', 'a123'], \ ['fileformats', 'mac', 'a123'], |