From ec53d43f844149f191ae23300db663436eda6d72 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Nov 2020 19:34:48 -0500 Subject: [PATCH 1/9] vim-patch:8.2.2041: haskell filetype not optimally recognized Problem: Haskell filetype not optimally recognized. Solution: Recognize all *.hsc files as Haskell. (Marcin Szamotulski, closes vim/vim#7354) https://github.com/vim/vim/commit/a09bee322e605c8a076fa23c3d3259495a1129d2 --- runtime/filetype.vim | 8 +------- src/nvim/testdir/test_filetype.vim | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 4e54bcaefd..b9d2a43d5d 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -693,15 +693,9 @@ au BufNewFile,BufRead *.haml setf haml " Hamster Classic | Playground files au BufNewFile,BufRead *.hsm setf hamster -au BufNewFile,BufRead *.hsc - \ if match(join(getline(1,10), "\n"), '\%(^\|\n\)\s*\%({-#\_s*LANGUAGE\>\|\\)') != -1 | - \ setf haskell | - \ else | - \ setf hamster | - \ endif " Haskell -au BufNewFile,BufRead *.hs,*.hs-boot setf haskell +au BufNewFile,BufRead *.hs,*.hsc,*.hs-boot setf haskell au BufNewFile,BufRead *.lhs setf lhaskell au BufNewFile,BufRead *.chs setf chaskell au BufNewFile,BufRead cabal.project setf cabalproject diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index ed75bda7a5..52b5884c8b 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -200,8 +200,8 @@ let s:filename_checks = { \ 'gsp': ['file.gsp'], \ 'gtkrc': ['.gtkrc', 'gtkrc'], \ 'haml': ['file.haml'], - \ 'hamster': ['file.hsc', 'file.hsm'], - \ 'haskell': ['file.hs', 'file.hs-boot'], + \ 'hamster': ['file.hsm'], + \ 'haskell': ['file.hs', 'file.hsc', 'file.hs-boot'], \ 'haste': ['file.ht'], \ 'hastepreproc': ['file.htpp'], \ 'hb': ['file.hb'], From 3a573a9e2fccf623e17a5c0482e8bc02545d4606 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Nov 2020 22:17:04 -0500 Subject: [PATCH 2/9] vim-patch:8.1.2290: autocommand test fails Problem: Autocommand test fails. Solution: Remove 'closeoff' from 'diffopt'. https://github.com/vim/vim/commit/a9aa86ff951b7908b615a61a0e216901b96bc0eb --- src/nvim/testdir/test_autocmd.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 04a678eeb8..01ff8c7129 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -696,6 +696,7 @@ func Test_OptionSet_diffmode_close() call setline(1, ['buffer 2', 'line 2', 'line 3', 'line4']) call assert_fails(':diffthis', 'E788') call assert_equal(1, &diff) + set diffopt-=closeoff bw! call assert_fails(':diffoff!', 'E788') bw! From eae90b37c37410f2f28c66c8b4535e5a5ce65cc8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Nov 2020 22:25:23 -0500 Subject: [PATCH 3/9] vim-patch:8.2.0302: setting 'term' may cause error in TermChanged autocommand Problem: Setting 'term' may cause error in TermChanged autocommand. Solution: Use aucmd_prepbuf() to switch to the buffer where the autocommand is to be executed. (closes vim/vim#5682) https://github.com/vim/vim/commit/0c81d1b11278b2d962aa6fbb4aa974dab97be59d --- src/nvim/testdir/test_autocmd.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 01ff8c7129..f1c1d45ada 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1857,6 +1857,26 @@ func Test_FileChangedShell_reload() call delete('Xchanged') endfunc +func LogACmd() + call add(g:logged, line('$')) +endfunc + +func Test_TermChanged() + enew! + tabnew + call setline(1, ['a', 'b', 'c', 'd']) + $ + au TermChanged * call LogACmd() + let g:logged = [] + let term_save = &term + set term=xterm + call assert_equal([1, 4], g:logged) + + au! TermChanged + let &term = term_save + bwipe! +endfunc + " Test for FileReadCmd autocmd func Test_autocmd_FileReadCmd() func ReadFileCmd() From b0d3f47e9044988e433a7e299e3080b0f33a21bc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Nov 2020 22:30:01 -0500 Subject: [PATCH 4/9] vim-patch:8.2.0303: TermChanged test fails in the GUI Problem: TermChanged test fails in the GUI. Solution: Skip the test when running the GUI. https://github.com/vim/vim/commit/d28e0b3652067788fcc9c99058b0b6eee7beebee --- src/nvim/testdir/test_autocmd.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index f1c1d45ada..22f03e1076 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1862,6 +1862,9 @@ func LogACmd() endfunc func Test_TermChanged() + throw 'skipped: Nvim does not support TermChanged event' + CheckNotGui + enew! tabnew call setline(1, ['a', 'b', 'c', 'd']) From a9186501f6070a655f96207881a54bf509bd79ce Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Nov 2020 01:26:52 -0500 Subject: [PATCH 5/9] vim-patch:8.1.2390: test94 is old style, fix 7.4.441 not tested Problem: Test94 is old style, fix 7.4.441 not tested. Solution: Turn test94 into a new style test. Add tests for the fix in patch 7.4.441. (Yegappan Lakshmanan, closes vim/vim#5316) https://github.com/vim/vim/commit/309976ec1f033c68480bbc8cc363db5b5ea944f9 --- src/nvim/testdir/test_cmdline.vim | 21 +++ src/nvim/testdir/test_visual.vim | 298 ++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index e3c42a4fe3..400e53d009 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -796,6 +796,27 @@ func Test_cmdwin_feedkeys() call feedkeys("q:\", 'x') endfunc +" Tests for the issues fixed in 7.4.441. +" When 'cedit' is set to Ctrl-C, opening the command window hangs Vim +func Test_cmdwin_cedit() + exe "set cedit=\" + normal! : + call assert_equal(1, winnr('$')) + + let g:cmd_wintype = '' + func CmdWinType() + let g:cmd_wintype = getcmdwintype() + return '' + endfunc + + call feedkeys("\a\=CmdWinType()\\") + echo input('') + call assert_equal('@', g:cmd_wintype) + + set cedit&vim + delfunc CmdWinType +endfunc + func Test_buffers_lastused() " check that buffers are sorted by time when wildmode has lastused edit bufc " oldest diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 734f264672..7f50894f66 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -442,4 +442,302 @@ func Test_visual_put_in_block() bwipe! endfunc +" Visual modes (v V CTRL-V) followed by an operator; count; repeating +func Test_visual_mode_op() + new + call append(0, '') + + call setline(1, 'apple banana cherry') + call cursor(1, 1) + normal lvld.l3vd. + call assert_equal('a y', getline(1)) + + call setline(1, ['line 1 line 1', 'line 2 line 2', 'line 3 line 3', + \ 'line 4 line 4', 'line 5 line 5', 'line 6 line 6']) + call cursor(1, 1) + exe "normal Vcnewline\j.j2Vd." + call assert_equal(['newline', 'newline'], getline(1, '$')) + + call deletebufline('', 1, '$') + call setline(1, ['xxxxxxxxxxxxx', 'xxxxxxxxxxxxx', 'xxxxxxxxxxxxx', + \ 'xxxxxxxxxxxxx']) + exe "normal \jlc \l.l2\c----\l." + call assert_equal([' --------x', + \ ' --------x', + \ 'xxxx--------x', + \ 'xxxx--------x'], getline(1, '$')) + + bwipe! +endfunc + +" Visual mode maps (movement and text object) +" Visual mode maps; count; repeating +" - Simple +" - With an Ex command (custom text object) +func Test_visual_mode_maps() + new + call append(0, '') + + func SelectInCaps() + let [line1, col1] = searchpos('\u', 'bcnW') + let [line2, col2] = searchpos('.\u', 'nW') + call setpos("'<", [0, line1, col1, 0]) + call setpos("'>", [0, line2, col2, 0]) + normal! gv + endfunction + + vnoremap W /\u/s-1 + vnoremap iW :call SelectInCaps() + + call setline(1, 'KiwiRaspberryDateWatermelonPeach') + call cursor(1, 1) + exe "normal vWcNo\l.fD2vd." + call assert_equal('NoNoberryach', getline(1)) + + call setline(1, 'JambuRambutanBananaTangerineMango') + call cursor(1, 1) + exe "normal llviWc-\l.l2vdl." + call assert_equal('--ago', getline(1)) + + vunmap W + vunmap iW + bwipe! + delfunc SelectInCaps +endfunc + +" Operator-pending mode maps (movement and text object) +" - Simple +" - With Ex command moving the cursor +" - With Ex command and Visual selection (custom text object) +func Test_visual_oper_pending_mode_maps() + new + call append(0, '') + + func MoveToCap() + call search('\u', 'W') + endfunction + + func SelectInCaps() + let [line1, col1] = searchpos('\u', 'bcnW') + let [line2, col2] = searchpos('.\u', 'nW') + call setpos("'<", [0, line1, col1, 0]) + call setpos("'>", [0, line2, col2, 0]) + normal! gv + endfunction + + onoremap W /\u/ + onoremap W :call MoveToCap() + onoremap iW :call SelectInCaps() + + call setline(1, 'PineappleQuinceLoganberryOrangeGrapefruitKiwiZ') + call cursor(1, 1) + exe "normal cW-\l.l2.l." + call assert_equal('----Z', getline(1)) + + call setline(1, 'JuniperDurianZ') + call cursor(1, 1) + exe "normal g?\WfD." + call assert_equal('WhavcreQhevnaZ', getline(1)) + + call setline(1, 'LemonNectarineZ') + call cursor(1, 1) + exe "normal yiWPlciWNew\fr." + call assert_equal('LemonNewNewZ', getline(1)) + + ounmap W + ounmap W + ounmap iW + bwipe! + delfunc MoveToCap + delfunc SelectInCaps +endfunc + +" Patch 7.3.879: Properly abort Operator-pending mode for "dv:" etc. +func Test_op_pend_mode_abort() + new + call append(0, '') + + call setline(1, ['zzzz', 'zzzz']) + call cursor(1, 1) + + exe "normal dV:\dv:\" + call assert_equal(['zzz'], getline(1, 2)) + set nomodifiable + call assert_fails('exe "normal d:\"', 'E21:') + set modifiable + call feedkeys("dv:\dV:\", 'xt') + call assert_equal(['zzz'], getline(1, 2)) + set nomodifiable + let v:errmsg = '' + call feedkeys("d:\", 'xt') + call assert_true(v:errmsg !~# '^E21:') + set modifiable + + bwipe! +endfunc + +func Test_characterwise_visual_mode() + new + + " characterwise visual mode: replace last line + $put ='a' + let @" = 'x' + normal v$p + call assert_equal('x', getline('$')) + + " characterwise visual mode: delete middle line + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + normal G + normal kkv$d + call assert_equal(['', 'b', 'c'], getline(1, '$')) + + " characterwise visual mode: delete middle two lines + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + normal Gkkvj$d + call assert_equal(['', 'c'], getline(1, '$')) + + " characterwise visual mode: delete last line + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + normal Gv$d + call assert_equal(['', 'a', 'b', ''], getline(1, '$')) + + " characterwise visual mode: delete last two lines + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + normal Gkvj$d + call assert_equal(['', 'a', ''], getline(1, '$')) + + bwipe! +endfunc + +func Test_characterwise_select_mode() + new + + " Select mode maps + snoremap End> + snoremap Down> + snoremap Del> + + " characterwise select mode: delete middle line + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + exe "normal Gkkgh\\" + call assert_equal(['', 'b', 'c'], getline(1, '$')) + + " characterwise select mode: delete middle two lines + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + exe "normal Gkkgh\\\" + call assert_equal(['', 'c'], getline(1, '$')) + + " characterwise select mode: delete last line + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + exe "normal Ggh\\" + call assert_equal(['', 'a', 'b', ''], getline(1, '$')) + + " characterwise select mode: delete last two lines + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + exe "normal Gkgh\\\" + call assert_equal(['', 'a', ''], getline(1, '$')) + + sunmap End> + sunmap Down> + sunmap Del> + bwipe! +endfunc + +func Test_linewise_select_mode() + new + + " linewise select mode: delete middle line + call append('$', ['a', 'b', 'c']) + exe "normal GkkgH\" + call assert_equal(['', 'b', 'c'], getline(1, '$')) + + + " linewise select mode: delete middle two lines + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + exe "normal GkkgH\\" + call assert_equal(['', 'c'], getline(1, '$')) + + " linewise select mode: delete last line + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + exe "normal GgH\" + call assert_equal(['', 'a', 'b'], getline(1, '$')) + + " linewise select mode: delete last two lines + call deletebufline('', 1, '$') + call append('$', ['a', 'b', 'c']) + exe "normal GkgH\\" + call assert_equal(['', 'a'], getline(1, '$')) + + bwipe! +endfunc + +func Test_visual_mode_put() + new + + " v_p: replace last character with line register at middle line + call append('$', ['aaa', 'bbb', 'ccc']) + normal G + -2yank + normal k$vp + call assert_equal(['', 'aaa', 'bb', 'aaa', '', 'ccc'], getline(1, '$')) + + " v_p: replace last character with line register at middle line selecting + " newline + call deletebufline('', 1, '$') + call append('$', ['aaa', 'bbb', 'ccc']) + normal G + -2yank + normal k$v$p + call assert_equal(['', 'aaa', 'bb', 'aaa', 'ccc'], getline(1, '$')) + + " v_p: replace last character with line register at last line + call deletebufline('', 1, '$') + call append('$', ['aaa', 'bbb', 'ccc']) + normal G + -2yank + normal $vp + call assert_equal(['', 'aaa', 'bbb', 'cc', 'aaa', ''], getline(1, '$')) + + " v_p: replace last character with line register at last line selecting + " newline + call deletebufline('', 1, '$') + call append('$', ['aaa', 'bbb', 'ccc']) + normal G + -2yank + normal $v$p + call assert_equal(['', 'aaa', 'bbb', 'cc', 'aaa', ''], getline(1, '$')) + + bwipe! +endfunc + +func Test_select_mode_gv() + new + + " gv in exclusive select mode after operation + call append('$', ['zzz ', 'äà ']) + set selection=exclusive + normal Gkv3lyjv3lpgvcxxx + call assert_equal(['', 'zzz ', 'xxx '], getline(1, '$')) + + " gv in exclusive select mode without operation + call deletebufline('', 1, '$') + call append('$', 'zzz ') + set selection=exclusive + exe "normal G0v3l\gvcxxx" + call assert_equal(['', 'xxx '], getline(1, '$')) + + set selection&vim + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab From ede747c2cc84382e8746df8992ef0e403647ffde Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Nov 2020 01:32:48 -0500 Subject: [PATCH 6/9] vim-patch:8.2.0257: cannot recognize a terminal in a popup window Problem: Cannot recognize a terminal in a popup window. Solution: Add the win_gettype() function. https://github.com/vim/vim/commit/00f3b4e007af07870168bf044cecc9d544483953 --- runtime/doc/eval.txt | 16 ++++++++++++++++ src/nvim/eval.lua | 1 + src/nvim/eval/funcs.c | 21 +++++++++++++++++++++ src/nvim/testdir/test_cmdline.vim | 2 ++ 4 files changed, 40 insertions(+) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 7c6013f1b2..43c6bd6918 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2487,6 +2487,7 @@ wait({timeout}, {condition}[, {interval}]) wildmenumode() Number whether 'wildmenu' mode is active win_findbuf({bufnr}) List find windows containing {bufnr} win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab} +win_gettype([{nr}]) String type of window {nr} win_gotoid({expr}) Number go to |window-ID| {expr} win_id2tabwin({expr}) List get tab and window nr from |window-ID| win_id2win({expr}) Number get window nr from |window-ID| @@ -9277,6 +9278,21 @@ win_getid([{win} [, {tab}]]) *win_getid()* number {tab}. The first tab has number one. Return zero if the window cannot be found. +win_gettype([{nr}]) *win_gettype()* + Return the type of the window: + "popup" popup window |popup| + "command" command-line window |cmdwin| + (empty) normal window + "unknown" window {nr} not found + + When {nr} is omitted return the type of the current window. + When {nr} is given return the type of this window by number or + |window-ID|. + + Also see the 'buftype' option. When running a terminal in a + popup window then 'buftype' is "terminal" and win_gettype() + returns "popup". + win_gotoid({expr}) *win_gotoid()* Go to window with ID {expr}. This may also change the current tabpage. diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 6c316bb1fe..9f1994e299 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -385,6 +385,7 @@ return { wildmenumode={}, win_findbuf={args=1}, win_getid={args={0,2}}, + win_gettype={args={0,1}}, win_gotoid={args=1}, win_id2tabwin={args=1}, win_id2win={args=1}, diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 62a8022734..090133c868 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -10992,6 +10992,27 @@ static void f_win_getid(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_number = win_getid(argvars); } +/// "win_gettype(nr)" function +static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + win_T *wp = curwin; + + rettv->v_type = VAR_STRING; + rettv->vval.v_string = NULL; + if (argvars[0].v_type != VAR_UNKNOWN) { + wp = find_win_by_nr_or_id(&argvars[0]); + if (wp == NULL) { + rettv->vval.v_string = vim_strsave((char_u *)"unknown"); + return; + } + } + if (wp->w_floating) { + rettv->vval.v_string = vim_strsave((char_u *)"popup"); + } else if (wp == curwin && cmdwin_type != 0) { + rettv->vval.v_string = vim_strsave((char_u *)"command"); + } +} + /// "win_gotoid()" function static void f_win_gotoid(typval_T *argvars, typval_T *rettv, FunPtr fptr) { diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 400e53d009..81f653c393 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -806,12 +806,14 @@ func Test_cmdwin_cedit() let g:cmd_wintype = '' func CmdWinType() let g:cmd_wintype = getcmdwintype() + let g:wintype = win_gettype() return '' endfunc call feedkeys("\a\=CmdWinType()\\") echo input('') call assert_equal('@', g:cmd_wintype) + call assert_equal('command', g:wintype) set cedit&vim delfunc CmdWinType From 9b2efe6b7d40d6ef317751768a65c74e4e2e8152 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Nov 2020 02:27:10 -0500 Subject: [PATCH 7/9] vim-patch:8.2.0991: cannot get window type for autocmd and preview window Problem: Cannot get window type for autocmd and preview window. Solution: Add types to win_gettype(). (Yegappan Lakshmanan, closes vim/vim#6277) https://github.com/vim/vim/commit/0fe937fd8616fcd24b1b1ef2ab9f1657615dd22c Cherry-pick test_preview.vim,test_window_cmd.vim changes from patch v8.2.0522. --- runtime/doc/eval.txt | 3 ++ src/nvim/eval/funcs.c | 6 +++- src/nvim/testdir/test_autocmd.vim | 22 ++++++++++++++ src/nvim/testdir/test_preview.vim | 44 ++++++++++++++++++++++++++++ src/nvim/testdir/test_window_cmd.vim | 33 --------------------- 5 files changed, 74 insertions(+), 34 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 43c6bd6918..57d9eb5b43 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -9280,7 +9280,10 @@ win_getid([{win} [, {tab}]]) *win_getid()* win_gettype([{nr}]) *win_gettype()* Return the type of the window: + "aucmdwin" autocommand window. Temporary window + used to execute autocommands. "popup" popup window |popup| + "preview" preview window |preview-window| "command" command-line window |cmdwin| (empty) normal window "unknown" window {nr} not found diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 090133c868..d07efc297e 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -11006,7 +11006,11 @@ static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } } - if (wp->w_floating) { + if (wp == aucmd_win) { + rettv->vval.v_string = vim_strsave((char_u *)"aucmdwin"); + } else if (wp->w_p_pvw) { + rettv->vval.v_string = vim_strsave((char_u *)"preview"); + } else if (wp->w_floating) { rettv->vval.v_string = vim_strsave((char_u *)"popup"); } else if (wp == curwin && cmdwin_type != 0) { rettv->vval.v_string = vim_strsave((char_u *)"command"); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 22f03e1076..a2695ec354 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1934,4 +1934,26 @@ func Test_autocmd_sigusr1() unlet g:sigusr1_passed endfunc +" Test for the temporary internal window used to execute autocmds +func Test_autocmd_window() + %bw! + edit one.txt + tabnew two.txt + let g:blist = [] + augroup aucmd_win_test + au! + au BufEnter * call add(g:blist, [expand(''), + \ win_gettype(bufwinnr(expand('')))]) + augroup END + + doautoall BufEnter + call assert_equal([['one.txt', 'aucmdwin'], ['two.txt', '']], g:blist) + + augroup aucmd_win_test + au! + augroup END + augroup! aucmd_win_test + %bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_preview.vim b/src/nvim/testdir/test_preview.vim index 91923fb1e9..6c4ae414d3 100644 --- a/src/nvim/testdir/test_preview.vim +++ b/src/nvim/testdir/test_preview.vim @@ -11,3 +11,47 @@ func Test_Psearch() call assert_equal(wincount, winnr('$')) bwipe endfunc + +func Test_window_preview() + " Open a preview window + pedit Xa + call assert_equal(2, winnr('$')) + call assert_equal(0, &previewwindow) + + " Go to the preview window + wincmd P + call assert_equal(1, &previewwindow) + call assert_equal('preview', win_gettype()) + + " Close preview window + wincmd z + call assert_equal(1, winnr('$')) + call assert_equal(0, &previewwindow) + + call assert_fails('wincmd P', 'E441:') +endfunc + +func Test_window_preview_from_help() + filetype on + call writefile(['/* some C code */'], 'Xpreview.c') + help + pedit Xpreview.c + wincmd P + call assert_equal(1, &previewwindow) + call assert_equal('c', &filetype) + wincmd z + + filetype off + close + call delete('Xpreview.c') +endfunc + +func Test_multiple_preview_windows() + new + set previewwindow + new + call assert_fails('set previewwindow', 'E590:') + %bw! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index 500e3ff088..c630e678fd 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -172,39 +172,6 @@ func Test_window_split_edit_bufnr() %bw! endfunc -func Test_window_preview() - " Open a preview window - pedit Xa - call assert_equal(2, winnr('$')) - call assert_equal(0, &previewwindow) - - " Go to the preview window - wincmd P - call assert_equal(1, &previewwindow) - - " Close preview window - wincmd z - call assert_equal(1, winnr('$')) - call assert_equal(0, &previewwindow) - - call assert_fails('wincmd P', 'E441:') -endfunc - -func Test_window_preview_from_help() - filetype on - call writefile(['/* some C code */'], 'Xpreview.c') - help - pedit Xpreview.c - wincmd P - call assert_equal(1, &previewwindow) - call assert_equal('c', &filetype) - wincmd z - - filetype off - close - call delete('Xpreview.c') -endfunc - func Test_window_exchange() e Xa From 8d7fa8962bce98936cf9ddcefd70f35e7db04239 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Nov 2020 02:43:23 -0500 Subject: [PATCH 8/9] vim-patch:8.2.0996: using "aucmdwin" in win_gettype() is not ideal Problem: Using "aucmdwin" in win_gettype() is not ideal. Solution: Rename to "autocmd". https://github.com/vim/vim/commit/40a019f157c549dcdc17c33f082975485567bb06 --- runtime/doc/eval.txt | 2 +- src/nvim/eval/funcs.c | 2 +- src/nvim/testdir/test_autocmd.vim | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 57d9eb5b43..343e35bf66 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -9280,7 +9280,7 @@ win_getid([{win} [, {tab}]]) *win_getid()* win_gettype([{nr}]) *win_gettype()* Return the type of the window: - "aucmdwin" autocommand window. Temporary window + "autocmd" autocommand window. Temporary window used to execute autocommands. "popup" popup window |popup| "preview" preview window |preview-window| diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index d07efc297e..901f20bedf 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -11007,7 +11007,7 @@ static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } if (wp == aucmd_win) { - rettv->vval.v_string = vim_strsave((char_u *)"aucmdwin"); + rettv->vval.v_string = vim_strsave((char_u *)"autocmd"); } else if (wp->w_p_pvw) { rettv->vval.v_string = vim_strsave((char_u *)"preview"); } else if (wp->w_floating) { diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index a2695ec354..1fa7eeaea0 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1947,7 +1947,7 @@ func Test_autocmd_window() augroup END doautoall BufEnter - call assert_equal([['one.txt', 'aucmdwin'], ['two.txt', '']], g:blist) + call assert_equal([['one.txt', 'autocmd'], ['two.txt', '']], g:blist) augroup aucmd_win_test au! From fe5dc266483aa4878b30ecc660b5401648545f27 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Nov 2020 21:59:54 -0500 Subject: [PATCH 9/9] vim-patch:8.2.0462: previewwindow test fails on some systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Previewwindow test fails on some systems. (James McCoy) Solution: Wait a bit after sending the "o". (closes vim/vim#5849) https://github.com/vim/vim/commit/37bb030cd9088ee66dc2d41c2d3602d1e5f4a7ef Cherry-pick Test_popup_and_previewwindow_dump() changes from patches 8.1.1585, 8.1.2373. N/A patches for version.c: vim-patch:8.2.0242: preview popup window test fails with long directory name Problem: Preview popup window test fails with long directory name. (Jakub Kądziołka) Solution: Use "silent cd". (closes vim/vim#5615) https://github.com/vim/vim/commit/799439a5d85a7d45eff7485056f2798cea766300 vim-patch:8.2.2042: build failure with +profile but without +reltime Problem: Build failure with +profile but without +reltime. Solution: Adjust #ifdef. (Christian Brabandt, closes vim/vim#7361) https://github.com/vim/vim/commit/813196784ad2a3a8cd65be5e975769d9768a728e vim-patch:8.2.2043: GTK3: white border around text stands out Problem: GTK3: white border around text stands out. Solution: Use current theme color. (closes vim/vim#7357, issue vim/vim#349) https://github.com/vim/vim/commit/ff94bd9e4779b918f3761035f43a97ba7175b3ce vim-patch:8.2.2047: Amiga: FEAT_ARP defined when it should not Problem: Amiga: FEAT_ARP defined when it should not. Solution: Adjust #ifdef. (Ola Söder, closes vim/vim#7370) https://github.com/vim/vim/commit/36fe7b287e13a7534c9aa6dcf0c3d7f8363f6060 vim-patch:8.2.2048: Amiga: obsolete code Problem: Amiga: obsolete code. Solution: Remove the unused lines. (Ola Söder, closes vim/vim#7373) https://github.com/vim/vim/commit/3a3b6910421ee1d03c222efc62d61b9fb879d931 vim-patch:8.2.2049: Amiga: obsolete function Problem: Amiga: obsolete function. Solution: Remove the function. (Ola Söder, closes vim/vim#7374) https://github.com/vim/vim/commit/d653293c806c8bea976737b88006264e7a8ea6d6 vim-patch:8.2.2054: Amiga: FEAT_ARP defined when it should not Problem: Amiga: FEAT_ARP defined when it should not. Solution: Adjust "||" to "&&" in #ifdef. (Ola Söder, closes vim/vim#7375) https://github.com/vim/vim/commit/d49a35a1c3b736637733b36011fccbee7ef43fcf --- src/nvim/testdir/test_popup.vim | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index fb464d95ea..4ee16558a0 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -735,20 +735,25 @@ func Test_popup_and_preview_autocommand() endfunc func Test_popup_and_previewwindow_dump() - if !CanRunVimInTerminal() - return - endif - call writefile([ - \ 'set previewheight=9', - \ 'silent! pedit', - \ 'call setline(1, map(repeat(["ab"], 10), "v:val. v:key"))', - \ 'exec "norm! G\\"', - \ ], 'Xscript') + CheckScreendump + CheckFeature quickfix + + let lines =<< trim END + set previewheight=9 + silent! pedit + call setline(1, map(repeat(["ab"], 10), "v:val .. v:key")) + exec "norm! G\\" + END + call writefile(lines, 'Xscript') let buf = RunVimInTerminal('-S Xscript', {}) + " wait for the script to finish + call term_wait(buf) + " Test that popup and previewwindow do not overlap. - call term_sendkeys(buf, "o\\") - sleep 100m + call term_sendkeys(buf, "o") + call term_wait(buf, 100) + call term_sendkeys(buf, "\\") call VerifyScreenDump(buf, 'Test_popup_and_previewwindow_01', {}) call term_sendkeys(buf, "\u")