From 53c9500c1dc95eb446e13e857a7d6a7642d859ab Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Aug 2022 08:22:10 +0800 Subject: vim-patch:8.2.1535: it is not possible to specify cell widths of characters Problem: It is not possible to specify cell widths of characters. Solution: Add setcellwidths(). https://github.com/vim/vim/commit/08aac3c6192f0103cb87e280270a32b50e653be1 Co-Authored-By: delphinus --- src/nvim/testdir/test_utf8.vim | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim index 9b010a5dbc..c5dfd85e5e 100644 --- a/src/nvim/testdir/test_utf8.vim +++ b/src/nvim/testdir/test_utf8.vim @@ -140,6 +140,41 @@ func Test_list2str_str2list_latin1() call assert_equal(s, sres) endfunc +func Test_setcellwidths() + call setcellwidths([ + \ [0x1330, 0x1330, 2], + \ [0x1337, 0x1339, 2], + \ [9999, 10000, 1], + \]) + + call assert_equal(2, strwidth("\u1330")) + call assert_equal(1, strwidth("\u1336")) + call assert_equal(2, strwidth("\u1337")) + call assert_equal(2, strwidth("\u1339")) + call assert_equal(1, strwidth("\u133a")) + + call setcellwidths([]) + + call assert_fails('call setcellwidths(1)', 'E714:') + + call assert_fails('call setcellwidths([1, 2, 0])', 'E1109:') + + call assert_fails('call setcellwidths([[0x101]])', 'E1110:') + call assert_fails('call setcellwidths([[0x101, 0x102]])', 'E1110:') + call assert_fails('call setcellwidths([[0x101, 0x102, 1, 4]])', 'E1110:') + call assert_fails('call setcellwidths([["a"]])', 'E1110:') + + call assert_fails('call setcellwidths([[0x102, 0x101, 1]])', 'E1111:') + + call assert_fails('call setcellwidths([[0x101, 0x102, 0]])', 'E1112:') + call assert_fails('call setcellwidths([[0x101, 0x102, 3]])', 'E1112:') + + call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x115, 0x116, 2]])', 'E1113:') + call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x122, 0x123, 2]])', 'E1113:') + + call assert_fails('call setcellwidths([[0x33, 0x44, 2]])', 'E1114:') +endfunc + func Test_print_overlong() " Text with more composing characters than MB_MAXBYTES. new -- cgit From 967415d5277df25ee96d961ec0ab95ddfe01a611 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Aug 2022 12:01:57 +0800 Subject: vim-patch:8.2.1537: memory acccess error when using setcellwidths() Problem: Memory acccess error when using setcellwidths(). Solution: Use array and pointers correctly. https://github.com/vim/vim/commit/b06a6d59d12dbd67d55b3c46f6e5547e9103c931 --- src/nvim/testdir/test_utf8.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim index c5dfd85e5e..882e9623f6 100644 --- a/src/nvim/testdir/test_utf8.vim +++ b/src/nvim/testdir/test_utf8.vim @@ -143,8 +143,8 @@ endfunc func Test_setcellwidths() call setcellwidths([ \ [0x1330, 0x1330, 2], - \ [0x1337, 0x1339, 2], \ [9999, 10000, 1], + \ [0x1337, 0x1339, 2], \]) call assert_equal(2, strwidth("\u1330")) -- cgit From 9fedb6fd783b9ac48239bc7574779118eec3729a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Aug 2022 12:08:28 +0800 Subject: vim-patch:8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid Problem: setcellwidths() may make 'listchars' or 'fillchars' invalid. Solution: Check the value and give an error. (closes vim/vim#9024) https://github.com/vim/vim/commit/94358a1e6e640ca5ebeb295efdddd4e92b700673 Cherry-pick f_setcellwidths() change from patch 9.0.0036. Cherry-pick 'ambiwidth' docs update from runtime update 079ba76ae7a7. --- src/nvim/testdir/test_utf8.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim index 882e9623f6..ab3503c282 100644 --- a/src/nvim/testdir/test_utf8.vim +++ b/src/nvim/testdir/test_utf8.vim @@ -173,6 +173,16 @@ func Test_setcellwidths() call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x122, 0x123, 2]])', 'E1113:') call assert_fails('call setcellwidths([[0x33, 0x44, 2]])', 'E1114:') + + set listchars=tab:--\\u2192 + call assert_fails('call setcellwidths([[0x2192, 0x2192, 2]])', 'E834:') + + set fillchars=stl:\\u2501 + call assert_fails('call setcellwidths([[0x2501, 0x2501, 2]])', 'E835:') + + set listchars& + set fillchars& + call setcellwidths([]) endfunc func Test_print_overlong() -- cgit From 24bf0490ea3a16c14494358fe45437e43ca8d1d1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 9 Aug 2022 20:35:34 +0800 Subject: vim-patch:9.0.0176: checking character options is duplicated and incomplete (#19690) Problem: Checking character options is duplicated and incomplete. Solution: Move checking to check_chars_options(). (closes vim/vim#10863) https://github.com/vim/vim/commit/8ca29b6a3599b82b8822b7697cad63d0244c2d59 --- src/nvim/testdir/test_options.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index b10f0f5030..6e9f2d2377 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -368,9 +368,17 @@ func Test_set_errors() call assert_fails('set sessionoptions=curdir,sesdir', 'E474:') call assert_fails('set foldmarker={{{,', 'E474:') call assert_fails('set sessionoptions=sesdir,curdir', 'E474:') - call assert_fails('set listchars=trail:· ambiwidth=double', 'E834:') + setlocal listchars=trail:· + call assert_fails('set ambiwidth=double', 'E834:') + setlocal listchars=trail:- + setglobal listchars=trail:· + call assert_fails('set ambiwidth=double', 'E834:') set listchars& - call assert_fails('set fillchars=stl:· ambiwidth=double', 'E835:') + setlocal fillchars=stl:· + call assert_fails('set ambiwidth=double', 'E835:') + setlocal fillchars=stl:- + setglobal fillchars=stl:· + call assert_fails('set ambiwidth=double', 'E835:') set fillchars& call assert_fails('set fileencoding=latin1,utf-8', 'E474:') set nomodifiable -- cgit From ff1266aaaaba80f86ab9624eea8939d644d7e730 Mon Sep 17 00:00:00 2001 From: Jonas Strittmatter <40792180+smjonas@users.noreply.github.com> Date: Wed, 10 Aug 2022 13:44:57 +0200 Subject: vim-patch:9.0.0182: quarto files are not recognized (#19702) Problem: Quarto files are not recognized. Solution: Recognize quarto files by the extension. (Jonas Strittmatter, closes vim/vim#10880) https://github.com/vim/vim/commit/3a9687fb2749cb3da6e3bbf60cb9eaa81f7889ae --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index eedad15e9e..beaf5fdcfa 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -441,6 +441,7 @@ let s:filename_checks = { \ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi', 'SConstruct'], \ 'ql': ['file.ql', 'file.qll'], \ 'quake': ['anybaseq2/file.cfg', 'anyid1/file.cfg', 'quake3/file.cfg', 'baseq2/file.cfg', 'id1/file.cfg', 'quake1/file.cfg', 'some-baseq2/file.cfg', 'some-id1/file.cfg', 'some-quake1/file.cfg'], + \ 'quarto': ['file.qmd'], \ 'r': ['file.r'], \ 'radiance': ['file.rad', 'file.mat'], \ 'raku': ['file.pm6', 'file.p6', 'file.t6', 'file.pod6', 'file.raku', 'file.rakumod', 'file.rakudoc', 'file.rakutest'], -- cgit From 754892e59dc3ab65a92d22f315e88b716bc26d1d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 11:29:38 +0800 Subject: vim-patch:8.2.{1536,1540}: charclass() (#19748) vim-patch:8.2.1536: cannot get the class of a character; emoji widths are wrong Problem: Cannot get the class of a character; emoji widths are wrong in some environments. Solution: Add charclass(). Update some emoji widths. Add script to check emoji widths. https://github.com/vim/vim/commit/4e4473c927167fd24e5c8df90e0e8035080cf2da Use latest charclass() docs from Vim. Rewrite DoIt() in emoji_list.vim in Lua. Omit emoji table updates: - emoji_width update looks wrong as these added ranges are only double-width when followed by 0xFE0F. - Other updates are too old. vim-patch:8.2.1540: the user cannot try out emoji character widths Problem: The user cannot try out emoji character widths. Solution: Move the emoji script to the runtime/tools directory. https://github.com/vim/vim/commit/98945560c1ae6e2ddee820a7de718a36e3f4b6e5 --- src/nvim/testdir/test_functions.vim | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index c11e7b4fea..e0e0c1ca38 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1769,6 +1769,13 @@ func Test_char2nr() call assert_equal(12354, char2nr('あ', 1)) endfunc +func Test_charclass() + call assert_equal(0, charclass(' ')) + call assert_equal(1, charclass('.')) + call assert_equal(2, charclass('x')) + call assert_equal(3, charclass("\u203c")) +endfunc + func Test_eventhandler() call assert_equal(0, eventhandler()) endfunc -- cgit From 1de62b9ea17b08db0fe37caf1f054b7b809120c3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 12:25:01 +0800 Subject: fix(charclass): make behavior with empty str match latest Vim (#19749) Later Vim patches changed to return 0 for empty string and null string. Also update setcellwidth() docs to match latest Vim. --- src/nvim/testdir/test_functions.vim | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index e0e0c1ca38..44b6f0373e 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1774,6 +1774,8 @@ func Test_charclass() call assert_equal(1, charclass('.')) call assert_equal(2, charclass('x')) call assert_equal(3, charclass("\u203c")) + " this used to crash vim + call assert_equal(0, "xxx"[-1]->charclass()) endfunc func Test_eventhandler() -- cgit From a850b15e1968476e0f609a9d699cdf24fd13e3a2 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 13 Aug 2022 10:26:12 +0200 Subject: vim-patch:9.0.0195: metafun files are not recogized (#19746) Problem: Metafun files are not recogized. Solution: Add filetype detection patterns. https://github.com/vim/vim/commit/9032b9ceb6073288d75386dbcbd9d1982fa24080 --- src/nvim/testdir/test_filetype.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index beaf5fdcfa..fd0c095365 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -360,7 +360,7 @@ let s:filename_checks = { \ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'], \ 'moo': ['file.moo'], \ 'moonscript': ['file.moon'], - \ 'mp': ['file.mp'], + \ 'mp': ['file.mp', 'file.mpxl', 'file.mpiv', 'file.mpvi'], \ 'mplayerconf': ['mplayer.conf', '/.mplayer/config', 'any/.mplayer/config'], \ 'mrxvtrc': ['mrxvtrc', '.mrxvtrc'], \ 'msidl': ['file.odl', 'file.mof'], -- cgit From 33b49d5f55423a1a3174ad0ce42c4454871aa9f8 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 13 Aug 2022 15:11:03 +0200 Subject: vim-patch:9.0.0197: astro files are not detected (#19755) Problem: Astro files are not detected. Solution: Add a pattern to match Astro files. (Emilia Zapata, closes vim/vim#10904) https://github.com/vim/vim/commit/6a76e84f555da6d9ee57db80143e1e5eb85535ff --- src/nvim/testdir/test_filetype.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index fd0c095365..e3a8370661 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -71,6 +71,7 @@ let s:filename_checks = { \ 'asciidoc': ['file.asciidoc', 'file.adoc'], \ 'asn': ['file.asn', 'file.asn1'], \ 'asterisk': ['asterisk/file.conf', 'asterisk/file.conf-file', 'some-asterisk/file.conf', 'some-asterisk/file.conf-file'], + \ 'astro': ['file.astro'], \ 'atlas': ['file.atl', 'file.as'], \ 'autohotkey': ['file.ahk'], \ 'autoit': ['file.au3'], -- cgit From 02a4974418b7fb18c5034b7b2fc85ce4cde7d370 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 21:31:00 +0800 Subject: vim-patch:7.4.1168 (#19645) Problem: This doesn't give the right result: eval(string(v:true)). (Nikolay Pavlov) Solution: Make the string "v:true" instead of "true". https://github.com/vim/vim/commit/f48aa160fdd7b8caa7678e1a2139244dd2bdc547 --- src/nvim/testdir/test_exit.vim | 2 +- src/nvim/testdir/test_vimscript.vim | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_exit.vim b/src/nvim/testdir/test_exit.vim index befcaec2b2..37be293950 100644 --- a/src/nvim/testdir/test_exit.vim +++ b/src/nvim/testdir/test_exit.vim @@ -95,7 +95,7 @@ func Test_exit_code() [CODE] if RunVim(before, ['quit'], '') - call assert_equal(['qp = null', 'ep = null', 'lp = 0', 'l = 0'], readfile('Xtestout')) + call assert_equal(['qp = v:null', 'ep = v:null', 'lp = 0', 'l = 0'], readfile('Xtestout')) endif call delete('Xtestout') diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim index de4629451b..d16783cf31 100644 --- a/src/nvim/testdir/test_vimscript.vim +++ b/src/nvim/testdir/test_vimscript.vim @@ -1165,10 +1165,10 @@ func Test_type() " call assert_equal(0, 0 + v:none) call assert_equal(0, 0 + v:null) - call assert_equal('false', '' . v:false) - call assert_equal('true', '' . v:true) - " call assert_equal('none', '' . v:none) - call assert_equal('null', '' . v:null) + call assert_equal('v:false', '' . v:false) + call assert_equal('v:true', '' . v:true) + " call assert_equal('v:none', '' . v:none) + call assert_equal('v:null', '' . v:null) call assert_true(v:false == 0) call assert_false(v:false != 0) -- cgit From 3cf629022b6289a980c47cfae921f9aec1948585 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 21:47:52 +0800 Subject: vim-patch:9.0.0198: ml_get error when switching buffer in Visual mode (#19756) Problem: ml_get error when switching buffer in Visual mode. Solution: End Visual mode when switching buffer. (closes vim/vim#10902) https://github.com/vim/vim/commit/cfeb8a584be11758cf71ae02f6c937b06d6bb66f --- src/nvim/testdir/test_visual.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index f9ac0e0884..b6a8fb24a4 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1550,5 +1550,25 @@ func Test_visual_area_adjusted_when_hiding() bwipe! endfunc +func Test_switch_buffer_ends_visual_mode() + enew + call setline(1, 'foo') + set hidden + set virtualedit=all + let buf1 = bufnr() + enew + let buf2 = bufnr() + call setline(1, ['', '', '', '']) + call cursor(4, 5) + call feedkeys("\3k4h", 'xt') + exe 'buffer' buf1 + call assert_equal('n', mode()) + + set nohidden + set virtualedit= + bwipe! + exe 'bwipe!' buf2 +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 3a8b8591477b4802af73436e93bd1283d4bab518 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 15:46:20 +0800 Subject: vim-patch:8.2.0078: expanding works differently the second time Problem: Expanding works differently the second time. Solution: Keep the expanded name when redefining a function. (closes vim/vim#5425) https://github.com/vim/vim/commit/b9adef79eca6f95bc7376ff3a6a383e436c5d6ea --- src/nvim/testdir/test_vimscript.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim index d16783cf31..0f204cdd0c 100644 --- a/src/nvim/testdir/test_vimscript.vim +++ b/src/nvim/testdir/test_vimscript.vim @@ -1573,6 +1573,23 @@ func Test_script_local_func() enew! | close endfunc +func Test_script_expand_sfile() + let lines =<< trim END + func s:snr() + return expand('') + endfunc + let g:result = s:snr() + END + call writefile(lines, 'Xexpand') + source Xexpand + call assert_match('\d\+_snr', g:result) + source Xexpand + call assert_match('\d\+_snr', g:result) + + call delete('Xexpand') + unlet g:result +endfunc + func Test_compound_assignment_operators() " Test for number let x = 1 -- cgit From a10a23aae91a8356b36ac63f0917a556cfcaf976 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 15:49:33 +0800 Subject: vim-patch:8.2.0097: crash with autocommand and spellfile Problem: Crash with autocommand and spellfile. (Tim Pope) Solution: Do not pop exestack when not pushed. (closes vim/vim#5450) https://github.com/vim/vim/commit/ce6db0273f2c4359f48d75103a42991aa481f14e --- src/nvim/testdir/test_autocmd.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 1c2f86a584..89e3c9927b 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2614,6 +2614,28 @@ func Test_BufWrite_lockmarks() call delete('Xtest2') endfunc +func Test_FileType_spell() + if !isdirectory('/tmp') + throw "Skipped: requires /tmp directory" + endif + + " this was crashing with an invalid free() + setglobal spellfile=/tmp/en.utf-8.add + augroup crash + autocmd! + autocmd BufNewFile,BufReadPost crashfile setf somefiletype + autocmd BufNewFile,BufReadPost crashfile set ft=anotherfiletype + autocmd FileType anotherfiletype setlocal spell + augroup END + func! NoCrash() abort + edit /tmp/crashfile + endfunc + call NoCrash() + + au! crash + setglobal spellfile= +endfunc + " Test closing a window or editing another buffer from a FileChangedRO handler " in a readonly buffer func Test_FileChangedRO_winclose() -- cgit From b1faf5f0b92356c5abb434cbb978c1db34f89c4a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Aug 2022 19:11:36 +0800 Subject: vim-patch:8.2.4249: the timeout limit for spell suggestions is always 5000 (#19769) Problem: The timeout limit for spell suggestions is always 5000 milli seconds. Solution: Add the "timeout" entry to 'spellsuggest'. https://github.com/vim/vim/commit/585ee07cfef307b2fc828537e0d31fdc22d7e79f --- src/nvim/testdir/test_spell.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index 7744c5bcca..8ab8204b10 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -474,6 +474,16 @@ func Test_spellsuggest_option_expr() bwipe! endfunc +func Test_spellsuggest_timeout() + set spellsuggest=timeout:30 + set spellsuggest=timeout:-123 + set spellsuggest=timeout:999999 + call assert_fails('set spellsuggest=timeout', 'E474:') + call assert_fails('set spellsuggest=timeout:x', 'E474:') + call assert_fails('set spellsuggest=timeout:-x', 'E474:') + call assert_fails('set spellsuggest=timeout:--9', 'E474:') +endfunc + func Test_spellinfo() throw 'skipped: Nvim does not support enc=latin1' new -- cgit From 41d6b8a6d060a27a4841af678d6c6b2d111937a2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 Aug 2022 06:01:38 +0800 Subject: vim-patch:9.0.0207: stacktrace not shown when debugging (#19776) Problem: Stacktrace not shown when debugging. Solution: Set msg_scroll in msg_source(). (closes vim/vim#10917) https://github.com/vim/vim/commit/28c162f6f1f525882a9a60f10ab4836dee7eb59f --- src/nvim/testdir/test_options.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 6e9f2d2377..fdfc1c0f89 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -820,11 +820,16 @@ func Test_rightleftcmd() set rightleft& endfunc -" Test for the "debug" option +" Test for the 'debug' option func Test_debug_option() + " redraw to avoid matching previous messages + redraw set debug=beep exe "normal \" call assert_equal('Beep!', Screenline(&lines)) + call assert_equal('line 4:', Screenline(&lines - 1)) + " only match the final colon in the line that shows the source + call assert_match(':$', Screenline(&lines - 2)) set debug& endfunc -- cgit From 98ab0bb5f7d2138be0b6019769e237e42aafad1a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Aug 2022 06:32:00 +0800 Subject: vim-patch:8.2.1297: when a test fails it's often not easy to see where Problem: When a test fails it's often not easy to see what the call stack is. Solution: Add more entries from the call stack in the exception message. https://github.com/vim/vim/commit/a5d0423fa16f18b4576a2a07e50034e489587a7d Use docs from latest Vim. --- src/nvim/testdir/test_expand_func.vim | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_expand_func.vim b/src/nvim/testdir/test_expand_func.vim index b48c2e8a19..388620f87e 100644 --- a/src/nvim/testdir/test_expand_func.vim +++ b/src/nvim/testdir/test_expand_func.vim @@ -37,17 +37,28 @@ func Test_expand_sflnum() delcommand Flnum endfunc -func Test_expand_sfile() +func Test_expand_sfile_and_stack() call assert_match('test_expand_func\.vim$', s:sfile) - call assert_match('^function .*\.\.Test_expand_sfile$', expand('')) + let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack$' + call assert_match(expected , expand('')) + call assert_match(expected , expand('')) " Call in script-local function - call assert_match('^function .*\.\.Test_expand_sfile\[5\]\.\.\d\+_expand_sfile$', s:expand_sfile()) + call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.\d\+_expand_sfile$', s:expand_sfile()) " Call in command command Sfile echo expand('') - call assert_match('^function .*\.\.Test_expand_sfile$', trim(execute('Sfile'))) + call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack$', trim(execute('Sfile'))) delcommand Sfile + + " Use from sourced script. + let lines =<< trim END + let g:stack_value = expand('') + END + call writefile(lines, 'Xstack') + source Xstack + call assert_match('\ Date: Sun, 14 Aug 2022 07:07:32 +0800 Subject: vim-patch:8.2.1653: expand('') does not include the final line number Problem: Expand('') does not include the final line number. Solution: Add the line nuber. (closes vim/vim#6927) https://github.com/vim/vim/commit/4f25b1aba050b85fa97ca2316aa04dd4b0b22530 --- src/nvim/testdir/test_expand_func.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_expand_func.vim b/src/nvim/testdir/test_expand_func.vim index 388620f87e..3094aad3a4 100644 --- a/src/nvim/testdir/test_expand_func.vim +++ b/src/nvim/testdir/test_expand_func.vim @@ -39,9 +39,9 @@ endfunc func Test_expand_sfile_and_stack() call assert_match('test_expand_func\.vim$', s:sfile) - let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack$' - call assert_match(expected , expand('')) - call assert_match(expected , expand('')) + let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack' + call assert_match(expected .. '$', expand('')) + call assert_match(expected .. '\[4\]' , expand('')) " Call in script-local function call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.\d\+_expand_sfile$', s:expand_sfile()) @@ -53,11 +53,12 @@ func Test_expand_sfile_and_stack() " Use from sourced script. let lines =<< trim END + " comment here let g:stack_value = expand('') END call writefile(lines, 'Xstack') source Xstack - call assert_match('\ Date: Sun, 14 Aug 2022 07:18:06 +0800 Subject: vim-patch:8.2.1658: expand('') has trailing ".." Problem: Expand('') has trailing "..". Solution: Remove the "..". (closes vim/vim#6927) https://github.com/vim/vim/commit/a810db3f17d477e057059c72062c08fd97bcea43 --- src/nvim/testdir/test_expand_func.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_expand_func.vim b/src/nvim/testdir/test_expand_func.vim index 3094aad3a4..fc0f7619c4 100644 --- a/src/nvim/testdir/test_expand_func.vim +++ b/src/nvim/testdir/test_expand_func.vim @@ -58,7 +58,7 @@ func Test_expand_sfile_and_stack() END call writefile(lines, 'Xstack') source Xstack - call assert_match('\ Date: Sun, 26 Jun 2022 14:50:57 +0800 Subject: vim-patch:8.1.1189: mode is not cleared when leaving Insert mode Problem: Mode is not cleared when leaving Insert mode. Solution: Clear the mode when got_int is set. (Ozaki Kiichi, closes vim/vim#4270) https://github.com/vim/vim/commit/abc7c7fc5a098374f5543a237e6c9dd918848b34 --- src/nvim/testdir/test_bufline.vim | 2 +- src/nvim/testdir/test_messages.vim | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim index ffb8e3facd..579d3a5eb5 100644 --- a/src/nvim/testdir/test_bufline.vim +++ b/src/nvim/testdir/test_bufline.vim @@ -19,7 +19,7 @@ func Test_setbufline_getbufline() let b = bufnr('%') wincmd w call assert_equal(1, setbufline(b, 5, ['x'])) - call assert_equal(1, setbufline(1234, 1, ['x'])) + call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x'])) call assert_equal(0, setbufline(b, 4, ['d', 'e'])) call assert_equal(['c'], b->getbufline(3)) call assert_equal(['d'], getbufline(b, 4)) diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index a02d23b409..19d7d23cca 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -95,6 +95,37 @@ func Test_echoerr() call test_ignore_error('RESET') endfunc +func Test_mode_message_at_leaving_insert_by_ctrl_c() + if !has('terminal') || has('gui_running') + return + endif + + " Set custom statusline built by user-defined function. + let testfile = 'Xtest.vim' + call writefile([ + \ 'func StatusLine() abort', + \ ' return ""', + \ 'endfunc', + \ 'set statusline=%!StatusLine()', + \ 'set laststatus=2', + \ ], testfile) + + let rows = 10 + let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) + call term_wait(buf, 200) + call assert_equal('run', job_status(term_getjob(buf))) + + call term_sendkeys(buf, "i") + call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) + + call term_sendkeys(buf, ":qall!\") + call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) + exe buf . 'bwipe!' + call delete(testfile) +endfunc + func Test_echospace() set noruler noshowcmd laststatus=1 call assert_equal(&columns - 1, v:echospace) -- cgit From 93ba82183122b6b6e3d388d0e0fad4a538052803 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Jun 2022 15:39:09 +0800 Subject: vim-patch:8.1.1192: mode is not cleared when leaving Insert mode with mapped Esc Problem: Mode is not cleared when leaving Insert mode with mapped Esc. Solution: Clear the mode when redraw_cmdline is set. (closes vim/vim#4269) https://github.com/vim/vim/commit/4c25bd785aa8b565bf973cbba12ed36b76daaa4f --- src/nvim/testdir/test_messages.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index 19d7d23cca..e181641a3b 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -126,6 +126,34 @@ func Test_mode_message_at_leaving_insert_by_ctrl_c() call delete(testfile) endfunc +func Test_mode_message_at_leaving_insert_with_esc_mapped() + if !has('terminal') || has('gui_running') + return + endif + + " Set custom statusline built by user-defined function. + let testfile = 'Xtest.vim' + call writefile([ + \ 'set laststatus=2', + \ 'inoremap 00', + \ ], testfile) + + let rows = 10 + let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) + call term_wait(buf, 200) + call assert_equal('run', job_status(term_getjob(buf))) + + call term_sendkeys(buf, "i") + call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) + call term_sendkeys(buf, "\") + call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) + + call term_sendkeys(buf, ":qall!\") + call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) + exe buf . 'bwipe!' + call delete(testfile) +endfunc + func Test_echospace() set noruler noshowcmd laststatus=1 call assert_equal(&columns - 1, v:echospace) -- cgit From 55da52963b6e13ecc402b6574cf3bd396d11d23d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Jun 2022 15:54:00 +0800 Subject: vim-patch:8.2.5109: mode not updated after CTRL-O CTRL-C in Insert mode Problem: Mode not updated after CTRL-O CTRL-C in Insert mode. Solution: Set redraw_mode and use it. (closes vim/vim#10581) https://github.com/vim/vim/commit/7a1d32809bb5c1527314000983e75125d79192e0 --- src/nvim/testdir/test_normal.vim | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 7cb70aa2af..523b9b8781 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -3,6 +3,7 @@ source shared.vim source check.vim source view_util.vim +source screendump.vim func Setup_NewWindow() 10new @@ -2038,9 +2039,9 @@ func Test_normal33_g_cmd2() call assert_equal(2, line('.')) call assert_fails(':norm! g;', 'E662') call assert_fails(':norm! g,', 'E663') - let &ul=&ul + let &ul = &ul call append('$', ['a', 'b', 'c', 'd']) - let &ul=&ul + let &ul = &ul call append('$', ['Z', 'Y', 'X', 'W']) let a = execute(':changes') call assert_match('2\s\+0\s\+2', a) @@ -2889,6 +2890,20 @@ func Test_message_when_using_ctrl_c() bwipe! endfunc +func Test_mode_updated_after_ctrl_c() + CheckScreendump + + let buf = RunVimInTerminal('', {'rows': 5}) + call term_sendkeys(buf, "i") + call term_sendkeys(buf, "\") + " wait a moment so that the "-- (insert) --" message is displayed + call TermWait(buf, 50) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_mode_updated_1', {}) + + call StopVimInTerminal(buf) +endfunc + " Test for '[m', ']m', '[M' and ']M' " Jumping to beginning and end of methods in Java-like languages func Test_java_motion() -- cgit From 37586eac42b285b97e6b85e736750c4f15df068d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 17 Jul 2022 10:04:49 +0800 Subject: vim-patch:8.2.1786: various Normal mode commands not fully tested Problem: Various Normal mode commands not fully tested. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#7059) https://github.com/vim/vim/commit/8a9bc95eaec53f4e0c951ff8f2686ae5113a5709 Cherry-pick Test_normal_gdollar_cmd() change from patch 8.2.0540. --- src/nvim/testdir/test_normal.vim | 173 +++++++++++++++++++++++++++++----- src/nvim/testdir/test_regexp_utf8.vim | 4 +- src/nvim/testdir/test_registers.vim | 6 ++ src/nvim/testdir/test_spellfile.vim | 12 +++ src/nvim/testdir/test_tagjump.vim | 13 ++- src/nvim/testdir/test_visual.vim | 33 +++++-- 6 files changed, 207 insertions(+), 34 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 523b9b8781..1202f58d8d 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -655,6 +655,19 @@ func Test_normal15_z_scroll_vert() call assert_equal(21, winsaveview()['topline']) call assert_equal([0, 21, 2, 0, 9], getcurpos()) + " Test for z+ with [count] greater than buffer size + 1 + norm! 1000z+ + call assert_equal(' 100', getline('.')) + call assert_equal(100, winsaveview()['topline']) + call assert_equal([0, 100, 2, 0, 9], getcurpos()) + + " Test for z+ from the last buffer line + norm! Gz.z+ + call assert_equal(' 100', getline('.')) + call assert_equal(100, winsaveview()['topline']) + call assert_equal([0, 100, 2, 0, 9], getcurpos()) + " Test for z^ norm! 22z+0 norm! z^ @@ -662,6 +675,12 @@ func Test_normal15_z_scroll_vert() call assert_equal(12, winsaveview()['topline']) call assert_equal([0, 21, 2, 0, 9], getcurpos()) + " Test for z^ from first buffer line + norm! ggz^ + call assert_equal('1', getline('.')) + call assert_equal(1, winsaveview()['topline']) + call assert_equal([0, 1, 1, 0, 1], getcurpos()) + " Test for [count]z^ 1 norm! 30z^ @@ -741,6 +760,19 @@ func Test_normal16_z_scroll_hor() norm! yl call assert_equal('z', @0) + " Test for zs and ze with folds + %fold + norm! $zs + call assert_equal(26, col('.')) + call assert_equal(0, winsaveview()['leftcol']) + norm! yl + call assert_equal('z', @0) + norm! ze + call assert_equal(26, col('.')) + call assert_equal(0, winsaveview()['leftcol']) + norm! yl + call assert_equal('z', @0) + " cleanup set wrap listchars=eol:$ bw! @@ -834,6 +866,19 @@ func Test_vert_scroll_cmds() normal! 4H call assert_equal(33, line('.')) + " Test for using a large count value + %d + call setline(1, range(1, 4)) + norm! 6H + call assert_equal(4, line('.')) + + " Test for 'M' with folded lines + %d + call setline(1, range(1, 20)) + 1,5fold + norm! LM + call assert_equal(12, line('.')) + " Test for the CTRL-E and CTRL-Y commands with folds %d call setline(1, range(1, 10)) @@ -1214,6 +1259,13 @@ func Test_normal18_z_fold() norm! j call assert_equal('55', getline('.')) + " Test for zm with a count + 50 + set foldlevel=2 + norm! 3zm + call assert_equal(0, &foldlevel) + call assert_equal(49, foldclosed(line('.'))) + " Test for zM 48 set nofoldenable foldlevel=99 @@ -1421,6 +1473,15 @@ func Test_normal23_K() set iskeyword-=% set iskeyword-=\| + " Currently doesn't work in Nvim, see #19436 + " Test for specifying a count to K + " 1 + " com! -nargs=* Kprog let g:Kprog_Args = + " set keywordprg=:Kprog + " norm! 3K + " call assert_equal('3 version8', g:Kprog_Args) + " delcom Kprog + " Only expect "man" to work on Unix if !has("unix") || has('nvim') " Nvim K uses :terminal. #15398 let &keywordprg = k @@ -1868,6 +1929,30 @@ func Test_normal29_brace() bw! endfunc +" Test for section movements +func Test_normal_section() + new + let lines =<< trim [END] + int foo() + { + if (1) + { + a = 1; + } + } + [END] + call setline(1, lines) + + " jumping to a folded line using [[ should open the fold + 2,3fold + call cursor(5, 1) + call feedkeys("[[", 'xt') + call assert_equal(2, line('.')) + call assert_equal(-1, foldclosedend(line('.'))) + + close! +endfunc + " Test for ~ command func Test_normal30_changecase() new @@ -2912,25 +2997,26 @@ func Test_java_motion() call assert_beeps('normal! ]m') call assert_beeps('normal! [M') call assert_beeps('normal! ]M') - a -Piece of Java -{ - tt m1 { - t1; - } e1 - - tt m2 { - t2; - } e2 - - tt m3 { - if (x) - { - t3; - } - } e3 -} -. + let lines =<< trim [CODE] + Piece of Java + { + tt m1 { + t1; + } e1 + + tt m2 { + t2; + } e2 + + tt m3 { + if (x) + { + t3; + } + } e3 + } + [CODE] + call setline(1, lines) normal gg @@ -2983,14 +3069,21 @@ Piece of Java call assert_equal("{LF", getline('.')) call assert_equal([2, 2, 2], [line('.'), col('.'), virtcol('.')]) + call cursor(2, 1) + call assert_beeps('norm! 5]m') + + " jumping to a method in a fold should open the fold + 6,10fold + call feedkeys("gg3]m", 'xt') + call assert_equal([7, 8, 15], [line('.'), col('.'), virtcol('.')]) + call assert_equal(-1, foldclosedend(7)) + close! endfunc +" Tests for g cmds func Test_normal_gdollar_cmd() - if !has("jumplist") - return - endif - " Tests for g cmds + CheckFeature jumplist call Setup_NewWindow() " Make long lines that will wrap %s/$/\=repeat(' foobar', 10)/ @@ -3198,6 +3291,27 @@ func Test_normal_colon_op() close! endfunc +" Test for deleting or changing characters across lines with 'whichwrap' +" containing 's'. Should count as one character. +func Test_normal_op_across_lines() + new + set whichwrap& + call setline(1, ['one two', 'three four']) + exe "norm! $3d\" + call assert_equal(['one twhree four'], getline(1, '$')) + + call setline(1, ['one two', 'three four']) + exe "norm! $3c\x" + call assert_equal(['one twxhree four'], getline(1, '$')) + + set whichwrap+=l + call setline(1, ['one two', 'three four']) + exe "norm! $3x" + call assert_equal(['one twhree four'], getline(1, '$')) + close! + set whichwrap& +endfunc + " Test for 'w' and 'b' commands func Test_normal_word_move() new @@ -3271,6 +3385,19 @@ func Test_normal_vert_scroll_longline() close! endfunc +" Test for jumping in a file using % +func Test_normal_percent_jump() + new + call setline(1, range(1, 100)) + + " jumping to a folded line should open the fold + 25,75fold + call feedkeys('50%', 'xt') + call assert_equal(50, line('.')) + call assert_equal(-1, foldclosedend(50)) + close! +endfunc + " Some commands like yy, cc, dd, >>, << and !! accept a count after " typing the first letter of the command. func Test_normal_count_after_operator() diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index 191cd948ac..14b9724d67 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -522,8 +522,8 @@ endfunc func Test_search_with_end_offset() new call setline(1, ['', 'dog(a', 'cat(']) - exe "normal /(/e+" .. "\" - normal "ayn + exe "normal /(/e+\" + normal n"ayn call assert_equal("a\ncat(", @a) close! endfunc diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim index 52e745438d..604d5f6ccd 100644 --- a/src/nvim/testdir/test_registers.vim +++ b/src/nvim/testdir/test_registers.vim @@ -426,6 +426,12 @@ func Test_execute_register() @ call assert_equal(3, i) + " try to execute expression register and use a backspace to cancel it + new + call feedkeys("@=\ax\y", 'xt') + call assert_equal(['x', 'y'], getline(1, '$')) + close! + " cannot execute a register in operator pending mode call assert_beeps('normal! c@r') endfunc diff --git a/src/nvim/testdir/test_spellfile.vim b/src/nvim/testdir/test_spellfile.vim index b028e9d969..ef475a99e7 100644 --- a/src/nvim/testdir/test_spellfile.vim +++ b/src/nvim/testdir/test_spellfile.vim @@ -25,6 +25,18 @@ func Test_spell_normal() let cnt=readfile('./Xspellfile.add') call assert_equal('goood', cnt[0]) + " zg should fail in operator-pending mode + call assert_beeps('norm! czg') + + " zg fails in visual mode when not able to get the visual text + call assert_beeps('norm! ggVjzg') + norm! V + + " zg fails for a non-identifier word + call append(line('$'), '###') + call assert_fails('norm! Gzg', 'E349:') + $d + " Test for zw 2 norm! $zw diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim index 1dd656ece5..04c0218f74 100644 --- a/src/nvim/testdir/test_tagjump.vim +++ b/src/nvim/testdir/test_tagjump.vim @@ -1133,7 +1133,7 @@ endfunc " Test for [i, ]i, [I, ]I, [ CTRL-I, ] CTRL-I and CTRL-W i commands func Test_inc_search() new - call setline(1, ['1:foo', '2:foo', 'foo', '3:foo', '4:foo']) + call setline(1, ['1:foo', '2:foo', 'foo', '3:foo', '4:foo', '===']) call cursor(3, 1) " Test for [i and ]i @@ -1143,6 +1143,9 @@ func Test_inc_search() call assert_equal('3:foo', execute('normal ]i')) call assert_equal('4:foo', execute('normal 2]i')) call assert_fails('normal 3]i', 'E389:') + call assert_fails('normal G]i', 'E349:') + call assert_fails('normal [i', 'E349:') + call cursor(3, 1) " Test for :isearch call assert_equal('1:foo', execute('isearch foo')) @@ -1163,6 +1166,9 @@ func Test_inc_search() call assert_equal([ \ ' 1: 4 3:foo', \ ' 2: 5 4:foo'], split(execute('normal ]I'), "\n")) + call assert_fails('normal G]I', 'E349:') + call assert_fails('normal [I', 'E349:') + call cursor(3, 1) " Test for :ilist call assert_equal([ @@ -1188,6 +1194,9 @@ func Test_inc_search() exe "normal k2]\t" call assert_equal([5, 3], [line('.'), col('.')]) call assert_fails("normal 2k3]\t", 'E389:') + call assert_fails("normal G[\t", 'E349:') + call assert_fails("normal ]\t", 'E349:') + call cursor(3, 1) " Test for :ijump call cursor(3, 1) @@ -1212,6 +1221,8 @@ func Test_inc_search() close call assert_fails('3wincmd i', 'E387:') call assert_fails('6wincmd i', 'E389:') + call assert_fails("normal G\i", 'E349:') + call cursor(3, 1) " Test for :isplit isplit foo diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index b6a8fb24a4..0a12b3570a 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -378,14 +378,17 @@ endfunc func Test_Visual_paragraph_textobject() new - call setline(1, ['First line.', - \ '', - \ 'Second line.', - \ 'Third line.', - \ 'Fourth line.', - \ 'Fifth line.', - \ '', - \ 'Sixth line.']) + let lines =<< trim [END] + First line. + + Second line. + Third line. + Fourth line. + Fifth line. + + Sixth line. + [END] + call setline(1, lines) " When start and end of visual area are identical, 'ap' or 'ip' select " the whole paragraph. @@ -639,6 +642,20 @@ func Test_characterwise_visual_mode() normal Gkvj$d call assert_equal(['', 'a', ''], getline(1, '$')) + " characterwise visual mode: use a count with the visual mode + %d _ + call setline(1, 'one two three') + norm! vy5vy + call assert_equal('one t', @") + + " characterwise visual mode: use a count with the visual mode from the last + " line in the buffer + %d _ + call setline(1, ['one', 'two', 'three', 'four']) + norm! vj$y + norm! G1vy + call assert_equal('four', @") + " characterwise visual mode: replace a single character line and the eol %d _ call setline(1, "a") -- cgit From 76b4b1977ba3f3a1f630468a2ce89f47f2cedec4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Jul 2022 08:16:02 +0800 Subject: vim-patch:8.2.1799: some Normal mode commands not fully tested Problem: Some Normal mode commands not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#7073) https://github.com/vim/vim/commit/d1ad99b65470d3e754f6a0588a6b0dc2214a1eab Cherry-pick test_registers.vim change from patch 8.2.0644. --- src/nvim/testdir/test_gf.vim | 16 +++++++++++++ src/nvim/testdir/test_goto.vim | 18 ++++++++++++++ src/nvim/testdir/test_normal.vim | 41 +++++++++++++++++++++++++++++++- src/nvim/testdir/test_registers.vim | 5 ++++ src/nvim/testdir/test_tabpage.vim | 16 ++++++++----- src/nvim/testdir/test_visual.vim | 47 +++++++++++++++++++++++++------------ 6 files changed, 121 insertions(+), 22 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_gf.vim b/src/nvim/testdir/test_gf.vim index feae44e5ee..b2bb189688 100644 --- a/src/nvim/testdir/test_gf.vim +++ b/src/nvim/testdir/test_gf.vim @@ -191,6 +191,22 @@ func Test_gf_error() au! InsertCharPre bwipe! + + " gf is not allowed when buffer is locked + new + augroup Test_gf + au! + au OptionSet diff norm! gf + augroup END + call setline(1, ['Xfile1', 'line2', 'line3', 'line4']) + " Nvim does not support test_override() + " call test_override('starting', 1) + " call assert_fails('diffthis', 'E788:') + " call test_override('starting', 0) + augroup Test_gf + au! + augroup END + bw! endfunc " If a file is not found by 'gf', then 'includeexpr' should be used to locate diff --git a/src/nvim/testdir/test_goto.vim b/src/nvim/testdir/test_goto.vim index 49095400ef..6d029ffda2 100644 --- a/src/nvim/testdir/test_goto.vim +++ b/src/nvim/testdir/test_goto.vim @@ -122,6 +122,24 @@ func Test_gd() call XTest_goto_decl('gd', lines, 3, 14) endfunc +" Using gd to jump to a declaration in a fold +func Test_gd_with_fold() + new + let lines =<< trim END + #define ONE 1 + #define TWO 2 + #define THREE 3 + + TWO + END + call setline(1, lines) + 1,3fold + call feedkeys('Ggd', 'xt') + call assert_equal(2, line('.')) + call assert_equal(-1, foldclosedend(2)) + bw! +endfunc + func Test_gd_not_local() let lines =<< trim [CODE] int func1(void) diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 1202f58d8d..f125c860d5 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -492,6 +492,18 @@ func Test_normal11_showcmd() call assert_equal(3, line('$')) exe "norm! 0d3\2l" call assert_equal('obar2foobar3', getline('.')) + " test for the visual block size displayed in the status line + call setline(1, ['aaaaa', 'bbbbb', 'ccccc']) + call feedkeys("ggl\lljj", 'xt') + redraw! + call assert_match('3x3$', Screenline(&lines)) + call feedkeys("\", 'xt') + " test for visually selecting a multi-byte character + call setline(1, ["\U2206"]) + call feedkeys("ggv", 'xt') + redraw! + call assert_match('1-3$', Screenline(&lines)) + call feedkeys("v", 'xt') bw! endfunc @@ -897,6 +909,18 @@ func Test_vert_scroll_cmds() exe "normal \\" call assert_equal(h + 1, line('w$')) + " Test for CTRL-Y from the first line and CTRL-E from the last line + %d + set scrolloff=2 + call setline(1, range(1, 4)) + exe "normal gg\" + call assert_equal(1, line('w0')) + call assert_equal(1, line('.')) + exe "normal G4\\" + call assert_equal(4, line('w$')) + call assert_equal(4, line('.')) + set scrolloff& + " Using and in an empty buffer should beep %d call assert_beeps('exe "normal \"') @@ -945,6 +969,18 @@ func Test_vert_scroll_cmds() exe "normal \" call assert_equal(50, line('w0')) + " Test for . Page down. + %d + call setline(1, range(1, 100)) + call feedkeys("\", 'xt') + call assert_equal(14, line('w0')) + call assert_equal(28, line('w$')) + + " Test for . Page up. + call feedkeys("\", 'xt') + call assert_equal(1, line('w0')) + call assert_equal(15, line('w$')) + set foldenable& close! endfunc @@ -1953,7 +1989,7 @@ func Test_normal_section() close! endfunc -" Test for ~ command +" Test for changing case using u, U, gu, gU and ~ (tilde) commands func Test_normal30_changecase() new call append(0, 'This is a simple test: äüöß') @@ -1973,6 +2009,9 @@ func Test_normal30_changecase() call assert_equal('this is a SIMPLE TEST: ÄÜÖSS', getline('.')) norm! V~ call assert_equal('THIS IS A simple test: äüöss', getline('.')) + call assert_beeps('norm! c~') + %d + call assert_beeps('norm! ~') " Test for changing case across lines using 'whichwrap' call setline(1, ['aaaaaa', 'aaaaaa']) diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim index 604d5f6ccd..11dd3badb6 100644 --- a/src/nvim/testdir/test_registers.vim +++ b/src/nvim/testdir/test_registers.vim @@ -279,7 +279,12 @@ func Test_get_register() call feedkeys(":\r\", 'xt') call assert_equal("a\rb", histget(':', -1)) " Modified because of #6137 + call assert_fails('let r = getreg("=", [])', 'E745:') + call assert_fails('let r = getreg("=", 1, [])', 'E745:') enew! + + " Using a register in operator-pending mode should fail + call assert_beeps('norm! c"') endfunc func Test_set_register() diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index 07f35ddb4f..6d468ec9de 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -670,15 +670,19 @@ func Test_tabline_tabmenu() call assert_equal(3, tabpagenr('$')) " go to tab page 2 in operator-pending mode (should beep) - call assert_beeps('call feedkeys("f" .. TabLineSelectPageCode(2), "Lx!")') + call assert_beeps('call feedkeys("c" .. TabLineSelectPageCode(2), "Lx!")') + call assert_equal(2, tabpagenr()) + call assert_equal(3, tabpagenr('$')) " open new tab page before tab page 1 in operator-pending mode (should beep) - call assert_beeps('call feedkeys("f" .. TabMenuNewItemCode(1), "Lx!")') + call assert_beeps('call feedkeys("c" .. TabMenuNewItemCode(1), "Lx!")') + call assert_equal(1, tabpagenr()) + call assert_equal(4, tabpagenr('$')) " open new tab page after tab page 3 in normal mode call feedkeys(TabMenuNewItemCode(4), "Lx!") call assert_equal(4, tabpagenr()) - call assert_equal(4, tabpagenr('$')) + call assert_equal(5, tabpagenr('$')) " go to tab page 2 in insert mode call feedkeys("i" .. TabLineSelectPageCode(2) .. "\", "Lx!") @@ -686,17 +690,17 @@ func Test_tabline_tabmenu() " close tab page 2 in insert mode call feedkeys("i" .. TabMenuCloseItemCode(2) .. "\", "Lx!") - call assert_equal(3, tabpagenr('$')) + call assert_equal(4, tabpagenr('$')) " open new tab page before tab page 3 in insert mode call feedkeys("i" .. TabMenuNewItemCode(3) .. "\", "Lx!") call assert_equal(3, tabpagenr()) - call assert_equal(4, tabpagenr('$')) + call assert_equal(5, tabpagenr('$')) " open new tab page after tab page 4 in insert mode call feedkeys("i" .. TabMenuNewItemCode(5) .. "\", "Lx!") call assert_equal(5, tabpagenr()) - call assert_equal(5, tabpagenr('$')) + call assert_equal(6, tabpagenr('$')) %bw! endfunc diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 0a12b3570a..456f0e0edd 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -642,12 +642,6 @@ func Test_characterwise_visual_mode() normal Gkvj$d call assert_equal(['', 'a', ''], getline(1, '$')) - " characterwise visual mode: use a count with the visual mode - %d _ - call setline(1, 'one two three') - norm! vy5vy - call assert_equal('one t', @") - " characterwise visual mode: use a count with the visual mode from the last " line in the buffer %d _ @@ -1195,15 +1189,38 @@ func Test_exclusive_selection() close! endfunc -" Test for starting visual mode with a count. -" This test should be run without any previous visual modes. So this should be -" run as a first test. -func Test_AAA_start_visual_mode_with_count() - new - call setline(1, ['aaaaaaa', 'aaaaaaa', 'aaaaaaa', 'aaaaaaa']) - normal! gg2Vy - call assert_equal("aaaaaaa\naaaaaaa\n", @") - close! +" Test for starting linewise visual with a count. +" This test needs to be run without any previous visual mode. Otherwise the +" count will use the count from the previous visual mode. +func Test_linewise_visual_with_count() + let after =<< trim [CODE] + call setline(1, ['one', 'two', 'three', 'four']) + norm! 3Vy + call assert_equal("one\ntwo\nthree\n", @") + call writefile(v:errors, 'Xtestout') + qall! + [CODE] + if RunVim([], after, '') + call assert_equal([], readfile('Xtestout')) + call delete('Xtestout') + endif +endfunc + +" Test for starting characterwise visual with a count. +" This test needs to be run without any previous visual mode. Otherwise the +" count will use the count from the previous visual mode. +func Test_characterwise_visual_with_count() + let after =<< trim [CODE] + call setline(1, ['one two', 'three']) + norm! l5vy + call assert_equal("ne tw", @") + call writefile(v:errors, 'Xtestout') + qall! + [CODE] + if RunVim([], after, '') + call assert_equal([], readfile('Xtestout')) + call delete('Xtestout') + endif endfunc " Test for visually selecting an inner block (iB) -- cgit From 535e423a6ae31b7b49e52768d95d6ada5b854cbb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 Aug 2022 20:51:18 +0800 Subject: vim-patch:8.2.1803: a few failures are not tested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: A few failures are not tested. Solution: Test a few failures. (Dominique Pellé, closes vim/vim#7075) https://github.com/vim/vim/commit/afe8cf617013fd8c3f0189f1e1fa7a2a6a8f7511 Cherry-pick a line in Test_argdelete() from patch 8.2.1736. --- src/nvim/testdir/test_arglist.vim | 9 +++++++-- src/nvim/testdir/test_cmdline.vim | 4 ++++ src/nvim/testdir/test_listdict.vim | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim index ca7c8574cb..e2a859a5da 100644 --- a/src/nvim/testdir/test_arglist.vim +++ b/src/nvim/testdir/test_arglist.vim @@ -420,6 +420,8 @@ func Test_argdelete() call assert_equal(['b'], argv()) call assert_fails('argdelete', 'E610:') call assert_fails('1,100argdelete', 'E16:') + call assert_fails('argdel /\)/', 'E55:') + call assert_fails('1argdel 1', 'E474:') call Reset_arglist() args a b c d @@ -472,13 +474,16 @@ func Test_arglist_autocmd() new " redefine arglist; go to Xxx1 next! Xxx1 Xxx2 Xxx3 - " open window for all args + " open window for all args; Reading Xxx2 will change the arglist and the + " third window will get Xxx1: + " win 1: Xxx1 + " win 2: Xxx2 + " win 3: Xxx1 all call assert_equal('test file Xxx1', getline(1)) wincmd w wincmd w call assert_equal('test file Xxx1', getline(1)) - " should now be in Xxx2 rewind call assert_equal('test file Xxx2', getline(1)) diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 7aac731709..f95970223f 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -912,6 +912,10 @@ func Test_cmdline_complete_various() call feedkeys(":doautocmd User MyCmd a.c\\\"\", 'xt') call assert_equal("\"doautocmd User MyCmd a.c\", @:) + " completion of autocmd group after comma + call feedkeys(":doautocmd BufNew,BufEn\\\"\", 'xt') + call assert_equal("\"doautocmd BufNew,BufEnter", @:) + " completion for the :augroup command augroup XTest augroup END diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index aa66d86af1..2f4e1db4a1 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/src/nvim/testdir/test_listdict.vim @@ -649,6 +649,8 @@ func Test_reduce() call assert_fails("call reduce({}, { acc, val -> acc + val }, 1)", 'E897:') call assert_fails("call reduce(0, { acc, val -> acc + val }, 1)", 'E897:') call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E897:') + call assert_fails("call reduce([1, 2], 'Xdoes_not_exist')", 'E117:') + call assert_fails("echo reduce(0z01, { acc, val -> 2 * acc + val }, '')", 'E39:') let g:lut = [1, 2, 3, 4] func EvilRemove() -- cgit From e73517e34e0c0aab3d078e39251b03ab5b418d0f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 Aug 2022 21:03:24 +0800 Subject: vim-patch:8.2.3345: some code not covered by tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Some code not covered by tests. Solution: Add a few more tests. (Dominique Pellé, closes vim/vim#8757) https://github.com/vim/vim/commit/bfb2bb16bc69441fa3ec13caacb2c94637a8a0ec --- src/nvim/testdir/test_arglist.vim | 6 ++++++ src/nvim/testdir/test_cmdline.vim | 33 ++++++++++++++++++++----------- src/nvim/testdir/test_spellfile.vim | 27 +++++++++++++++++++++++++ src/nvim/testdir/test_substitute.vim | 38 ++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 11 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim index e2a859a5da..0a72e38755 100644 --- a/src/nvim/testdir/test_arglist.vim +++ b/src/nvim/testdir/test_arglist.vim @@ -87,6 +87,10 @@ func Test_argadd() new arga call assert_equal(0, len(argv())) + + if has('unix') + call assert_fails('argadd `Xdoes_not_exist`', 'E479:') + endif endfunc func Test_argadd_empty_curbuf() @@ -429,6 +433,8 @@ func Test_argdelete() argdel call Assert_argc(['a', 'c', 'd']) %argdel + + call assert_fails('argdel does_not_exist', 'E480:') endfunc func Test_argdelete_completion() diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index f95970223f..f1ca6dadfe 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -916,6 +916,14 @@ func Test_cmdline_complete_various() call feedkeys(":doautocmd BufNew,BufEn\\\"\", 'xt') call assert_equal("\"doautocmd BufNew,BufEnter", @:) + " completion of file name in :doautocmd + call writefile([], 'Xfile1') + call writefile([], 'Xfile2') + call feedkeys(":doautocmd BufEnter Xfi\\\"\", 'xt') + call assert_equal("\"doautocmd BufEnter Xfile1 Xfile2", @:) + call delete('Xfile1') + call delete('Xfile2') + " completion for the :augroup command augroup XTest augroup END @@ -1396,14 +1404,6 @@ func Test_cmdwin_jump_to_win() call assert_equal(1, winnr('$')) endfunc -" Test for backtick expression in the command line -func Test_cmd_backtick() - %argd - argadd `=['a', 'b', 'c']` - call assert_equal(['a', 'b', 'c'], argv()) - %argd -endfunc - func Test_cmdwin_tabpage() tabedit " v8.2.1919 isn't ported yet, so E492 is thrown after E11 here. @@ -1416,11 +1416,22 @@ func Test_cmdwin_tabpage() tabclose! endfunc +" Test for backtick expression in the command line +func Test_cmd_backtick() + CheckNotMSWindows " FIXME: see #19297 + %argd + argadd `=['a', 'b', 'c']` + call assert_equal(['a', 'b', 'c'], argv()) + %argd + + argadd `echo abc def` + call assert_equal(['abc def'], argv()) + %argd +endfunc + " Test for the :! command func Test_cmd_bang() - if !has('unix') - return - endif + CheckUnix let lines =<< trim [SCRIPT] " Test for no previous command diff --git a/src/nvim/testdir/test_spellfile.vim b/src/nvim/testdir/test_spellfile.vim index ef475a99e7..dbffbafed9 100644 --- a/src/nvim/testdir/test_spellfile.vim +++ b/src/nvim/testdir/test_spellfile.vim @@ -919,6 +919,33 @@ func Test_spellfile_COMMON() call delete('XtestCOMMON-utf8.spl') endfunc +" Test NOSUGGEST (see :help spell-COMMON) +func Test_spellfile_NOSUGGEST() + call writefile(['2', 'foo/X', 'fog'], 'XtestNOSUGGEST.dic') + call writefile(['NOSUGGEST X'], 'XtestNOSUGGEST.aff') + + mkspell! XtestNOSUGGEST-utf8.spl XtestNOSUGGEST + set spell spelllang=XtestNOSUGGEST-utf8.spl + + for goodword in ['foo', 'Foo', 'FOO', 'fog', 'Fog', 'FOG'] + call assert_equal(['', ''], spellbadword(goodword), goodword) + endfor + for badword in ['foO', 'fOO', 'fooo', 'foog', 'foofog', 'fogfoo'] + call assert_equal([badword, 'bad'], spellbadword(badword)) + endfor + + call assert_equal(['fog'], spellsuggest('fooo', 1)) + call assert_equal(['fog'], spellsuggest('fOo', 1)) + call assert_equal(['fog'], spellsuggest('foG', 1)) + call assert_equal(['fog'], spellsuggest('fogg', 1)) + + set spell& spelllang& + call delete('XtestNOSUGGEST.dic') + call delete('XtestNOSUGGEST.aff') + call delete('XtestNOSUGGEST-utf8.spl') +endfunc + + " Test CIRCUMFIX (see: :help spell-CIRCUMFIX) func Test_spellfile_CIRCUMFIX() " Example taken verbatim from https://github.com/hunspell/hunspell/tree/master/tests diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim index f795d1c0cf..b3a80072d9 100644 --- a/src/nvim/testdir/test_substitute.vim +++ b/src/nvim/testdir/test_substitute.vim @@ -858,6 +858,44 @@ func Test_substitute_skipped_range() bwipe! endfunc +" Test using the 'gdefault' option (when on, flag 'g' is default on). +func Test_substitute_gdefault() + new + + " First check without 'gdefault' + call setline(1, 'foo bar foo') + s/foo/FOO/ + call assert_equal('FOO bar foo', getline(1)) + call setline(1, 'foo bar foo') + s/foo/FOO/g + call assert_equal('FOO bar FOO', getline(1)) + call setline(1, 'foo bar foo') + s/foo/FOO/gg + call assert_equal('FOO bar foo', getline(1)) + + " Then check with 'gdefault' + set gdefault + call setline(1, 'foo bar foo') + s/foo/FOO/ + call assert_equal('FOO bar FOO', getline(1)) + call setline(1, 'foo bar foo') + s/foo/FOO/g + call assert_equal('FOO bar foo', getline(1)) + call setline(1, 'foo bar foo') + s/foo/FOO/gg + call assert_equal('FOO bar FOO', getline(1)) + + " Setting 'compatible' should reset 'gdefault' + call assert_equal(1, &gdefault) + " set compatible + set nogdefault + call assert_equal(0, &gdefault) + set nocompatible + call assert_equal(0, &gdefault) + + bw! +endfunc + " This was using "old_sub" after it was freed. func Test_using_old_sub() " set compatible maxfuncdepth=10 -- cgit From 747dec7925e130e754cf5ef1db87dd8747923514 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 Aug 2022 21:12:42 +0800 Subject: vim-patch:8.2.3392: augroup completion escapes regexp pattern characters Problem: augroup completion escapes regexp pattern characters. Solution: Do not escape the augroup name. (closes vim/vim#8826) https://github.com/vim/vim/commit/b4d82e2a8d610c00139a74970df772eece2daf1c --- src/nvim/testdir/test_cmdline.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index f1ca6dadfe..b9eefa937a 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -925,11 +925,13 @@ func Test_cmdline_complete_various() call delete('Xfile2') " completion for the :augroup command - augroup XTest + augroup XTest.test augroup END call feedkeys(":augroup X\\\"\", 'xt') - call assert_equal("\"augroup XTest", @:) - augroup! XTest + call assert_equal("\"augroup XTest.test", @:) + call feedkeys(":au X\\\"\", 'xt') + call assert_equal("\"au XTest.test", @:) + augroup! XTest.test " completion for the :unlet command call feedkeys(":unlet one two\\\"\", 'xt') -- cgit From 1d28bbf1e53fac5160a24b1194090a4e1c5b6046 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Aug 2022 05:37:49 +0800 Subject: vim-patch:9.0.0217: 'shellslash' works differently when sourcing a script again Problem: 'shellslash' works differently when sourcing a script again. Solution: Use the name from the script item. (closes vim/vim#10920) https://github.com/vim/vim/commit/5a4fff4d948cd12a5cf5f637ad2c561815a77d8e --- src/nvim/testdir/test_expand_func.vim | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_expand_func.vim b/src/nvim/testdir/test_expand_func.vim index fc0f7619c4..df01d84f19 100644 --- a/src/nvim/testdir/test_expand_func.vim +++ b/src/nvim/testdir/test_expand_func.vim @@ -41,7 +41,7 @@ func Test_expand_sfile_and_stack() call assert_match('test_expand_func\.vim$', s:sfile) let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack' call assert_match(expected .. '$', expand('')) - call assert_match(expected .. '\[4\]' , expand('')) + call assert_match(expected .. '\[4\]$' , expand('')) " Call in script-local function call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.\d\+_expand_sfile$', s:expand_sfile()) @@ -59,7 +59,32 @@ func Test_expand_sfile_and_stack() call writefile(lines, 'Xstack') source Xstack call assert_match('\') + set noshellslash + let g:stack2 = expand('') + set shellslash + let g:stack3 = expand('') + END + call writefile(lines, 'Xshellslash/Xstack') + " Test that changing 'shellslash' always affects the result of expand() + " when sourcing a script multiple times. + for i in range(2) + source Xshellslash/Xstack + call assert_match('\ Date: Tue, 16 Aug 2022 11:23:49 +0800 Subject: vim-patch:9.0.0216: undo earlier test sometimes fails on MS-Windows (#19790) Problem: Undo earlier test sometimes fails on MS-Windows. Solution: Use another file name. https://github.com/vim/vim/commit/cce293f87beb57a75ff738fade7fafadbc4a78a9 --- src/nvim/testdir/test_undo.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim index a9ec405aa4..eb47af08d7 100644 --- a/src/nvim/testdir/test_undo.vim +++ b/src/nvim/testdir/test_undo.vim @@ -336,7 +336,7 @@ func Test_undofile_earlier() " create undofile with timestamps older than Vim startup time. let t0 = localtime() - 43200 call test_settime(t0) - new Xfile + new XfileEarlier call feedkeys("ione\", 'xt') set ul=100 call test_settime(t0 + 1) @@ -350,12 +350,12 @@ func Test_undofile_earlier() bwipe! " restore normal timestamps. call test_settime(0) - new Xfile + new XfileEarlier rundo Xundofile earlier 1d call assert_equal('', getline(1)) bwipe! - call delete('Xfile') + call delete('XfileEarlier') call delete('Xundofile') endfunc -- cgit From da13ed43cb3593f6d50e08fc6e5f26760da63f84 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Aug 2022 15:29:36 +0800 Subject: vim-patch:8.2.3888: the argument list may contain duplicates (#19795) Problem: The argument list may contain duplicates. Solution: Add the :argdedeupe command. (Nir Lichtman, closes vim/vim#6235) https://github.com/vim/vim/commit/73a024209cbfbd5b39a2e974084d807c6131e2ed Use latest index.txt :argdedupe doc from Vim. --- src/nvim/testdir/test_arglist.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim index 0a72e38755..521c3fcd57 100644 --- a/src/nvim/testdir/test_arglist.vim +++ b/src/nvim/testdir/test_arglist.vim @@ -412,6 +412,35 @@ func Test_argedit() bw! x endfunc +" Test for the :argdedupe command +func Test_argdedupe() + call Reset_arglist() + argdedupe + call assert_equal([], argv()) + args a a a aa b b a b aa + argdedupe + call assert_equal(['a', 'aa', 'b'], argv()) + args a b c + argdedupe + call assert_equal(['a', 'b', 'c'], argv()) + args a + argdedupe + call assert_equal(['a'], argv()) + args a A b B + argdedupe + if has('fname_case') + call assert_equal(['a', 'A', 'b', 'B'], argv()) + else + call assert_equal(['a', 'b'], argv()) + endif + args a b a c a b + last + argdedupe + next + call assert_equal('c', expand('%:t')) + %argd +endfunc + " Test for the :argdelete command func Test_argdelete() call Reset_arglist() -- cgit From 65bcec9e9ba8f134536b9d3db1d5beac26991e17 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Aug 2022 08:58:51 +0800 Subject: vim-patch:9.0.0220: invalid memory access with for loop over NULL string Problem: Invalid memory access with for loop over NULL string. Solution: Make sure mb_ptr2len() consistently returns zero for NUL. https://github.com/vim/vim/commit/f6d39c31d2177549a986d170e192d8351bd571e2 --- src/nvim/testdir/test_eval_stuff.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_eval_stuff.vim b/src/nvim/testdir/test_eval_stuff.vim index 811c6c946d..eff1376d3c 100644 --- a/src/nvim/testdir/test_eval_stuff.vim +++ b/src/nvim/testdir/test_eval_stuff.vim @@ -75,6 +75,18 @@ func Test_for_invalid() redraw endfunc +func Test_for_over_null_string() + let save_enc = &enc + " set enc=iso8859 + let cnt = 0 + for c in v:_null_string + let cnt += 1 + endfor + call assert_equal(0, cnt) + + let &enc = save_enc +endfunc + func Test_readfile_binary() new call setline(1, ['one', 'two', 'three']) -- cgit From dd15fa70967a29e535ae189d387f2e813aaa07fb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Aug 2022 09:01:48 +0800 Subject: vim-patch:9.0.0222: no good reason why text objects are only in larger builds Problem: No good reason why text objects are only in larger builds. Solution: Graduate +textobjects. https://github.com/vim/vim/commit/887748742deae3d6de7aa0fdbb042afe1ccf5e7a --- src/nvim/testdir/test_textobjects.vim | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_textobjects.vim b/src/nvim/testdir/test_textobjects.vim index eeb2946a8b..f21d6fcb99 100644 --- a/src/nvim/testdir/test_textobjects.vim +++ b/src/nvim/testdir/test_textobjects.vim @@ -1,7 +1,6 @@ " Test for textobjects source check.vim -CheckFeature textobjects func CpoM(line, useM, expected) new -- cgit From 5977a96b3fa8283862d5768daebdbdaae84a8b3d Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Tue, 16 Aug 2022 14:45:31 +0900 Subject: vim-patch:9.0.0190: the way 'cmdheight' can be made zero is inconsistent Problem: The way 'cmdheight' can be made zero is inconsistent. Solution: Only make 'cmdheight' zero when setting it explicitly, not when resizing windows. (closes vim/vim#10890) https://github.com/vim/vim/commit/f797e309caff48f7a56c73b16e62ff67c4dcbdd6 --- src/nvim/testdir/test_cmdline.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index b9eefa937a..cac1491d63 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -126,6 +126,35 @@ func Test_wildmenu_screendump() call delete('XTest_wildmenu') endfunc +func Test_changing_cmdheight() + CheckScreendump + + let lines =<< trim END + set cmdheight=1 laststatus=2 + END + call writefile(lines, 'XTest_cmdheight') + + let buf = RunVimInTerminal('-S XTest_cmdheight', {'rows': 8}) + call term_sendkeys(buf, ":resize -3\") + call VerifyScreenDump(buf, 'Test_changing_cmdheight_1', {}) + + " using the space available doesn't change the status line + call term_sendkeys(buf, ":set cmdheight+=3\") + call VerifyScreenDump(buf, 'Test_changing_cmdheight_2', {}) + + " using more space moves the status line up + call term_sendkeys(buf, ":set cmdheight+=1\") + call VerifyScreenDump(buf, 'Test_changing_cmdheight_3', {}) + + " reducing cmdheight moves status line down + call term_sendkeys(buf, ":set cmdheight-=2\") + call VerifyScreenDump(buf, 'Test_changing_cmdheight_4', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XTest_cmdheight') +endfunc + func Test_map_completion() if !has('cmdline_compl') return -- cgit From 9a6d3bd76e1edcedf71f31dfa5e1600c1c5d2c3a Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Tue, 16 Aug 2022 14:58:41 +0900 Subject: vim-patch:9.0.0191: messages test fails; window size incorrect Problem: Messages test fails; window size incorrect when 'cmdheight' is made smaller. Solution: Properly cleanup after test with cmdheight zero. Resize windows correctly when 'cmdheight' gets smaller. https://github.com/vim/vim/commit/d4cf9fc53e0b1d36e84d28ecd5595a6f102f325e N/A patches for version.c: vim-patch:9.0.0192: possible invalid memory access when 'cmdheight' is zero Problem: Possible invalid memory access when 'cmdheight' is zero. (Martin Tournoij) Solution: Avoid going over the end of w_lines[] when w_height is Rows. (closes vim/vim#10882) https://github.com/vim/vim/commit/fdc5d17d58cc9c9edc9fb2816e1afaabc531bf1e --- src/nvim/testdir/test_cmdline.vim | 5 +++++ src/nvim/testdir/test_messages.vim | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index cac1491d63..b9f027afb2 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -150,6 +150,11 @@ func Test_changing_cmdheight() call term_sendkeys(buf, ":set cmdheight-=2\") call VerifyScreenDump(buf, 'Test_changing_cmdheight_4', {}) + " reducing window size and then setting cmdheight + call term_sendkeys(buf, ":resize -1\") + call term_sendkeys(buf, ":set cmdheight=1\") + call VerifyScreenDump(buf, 'Test_changing_cmdheight_5', {}) + " clean up call StopVimInTerminal(buf) call delete('XTest_cmdheight') diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index e181641a3b..3a607ff533 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -376,6 +376,7 @@ func Test_fileinfo_after_echo() endfunc func Test_cmdheight_zero() + enew set cmdheight=0 set showcmd redraw! @@ -425,10 +426,13 @@ func Test_cmdheight_zero() 7 call feedkeys(":\"\=line('w0')\\", "xt") call assert_equal('"1', @:) - bwipe! + bwipe! + bwipe! set cmdheight& set showcmd& + tabnew + tabonly endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From f5588ee8968c564f6f7b0e42ac0ad44f83489659 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 17 Aug 2022 17:50:40 +0600 Subject: feat: allow :wincmd to accept a count (#19815) Let :wincmd command accept a count like what its documentation suggests. Previously it could only accept a range, which led to some ambiguity on which attribute should be used when executing :wincmd using nvim_cmd. Closes #19662. Also fix a typo in a related Vim test: vim-patch:9.0.0223: typo in diffmode test Problem: Typo in diffmode test. Solution: Fix the typo. (closes vim/vim#10932) https://github.com/vim/vim/commit/5fd6ab820b4a0aaa5c6020852f39d118375fab49 --- src/nvim/testdir/test_diffmode.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index 1dbbe578c5..ea453b7174 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -137,7 +137,7 @@ func Common_vert_split() " Test diffoff diffoff! - 1wincmd 2 + 1wincmd w let &diff = 1 let &fdm = diff_fdm let &fdc = diff_fdc -- cgit From aa96a80d5df98d7fa888bd80eb7e4721e9e039f9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Aug 2022 20:34:46 +0800 Subject: vim-patch:8.2.3946: when an internal error makes Vim exit the error is not seen Problem: When an internal error makes Vim exit the error is not seen. Solution: Add the error to the test output. https://github.com/vim/vim/commit/1c67f3a9779b99bed7aacb3108abbb649445d3ed Add emsg_not_now() check to make code equivalent. --- src/nvim/testdir/runtest.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 6b16e888a9..fcd3d5724c 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -257,6 +257,7 @@ endfunc func EarlyExit(test) " It's OK for the test we use to test the quit detection. if a:test != 'Test_zz_quit_detected()' + call add(v:errors, v:errmsg) call add(v:errors, 'Test caused Vim to exit: ' . a:test) endif -- cgit From efebf30784951e88657e5c9362f374725a056a71 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Aug 2022 21:11:11 +0800 Subject: vim-patch:partial:8.2.0425: code for modeless selection not sufficiently tested Problem: Code for modeless selection not sufficiently tested. Solution: Add tests. Move mouse code functionality to a common script file. (Yegappan Lakshmanan, closes vim/vim#5821) https://github.com/vim/vim/commit/515545e11f523d14343b1e588dc0b9bd3d362bc2 Skip termcode tests for now. --- src/nvim/testdir/test_edit.vim | 16 ---- src/nvim/testdir/test_global.vim | 5 +- src/nvim/testdir/test_normal.vim | 25 ------ src/nvim/testdir/test_selectmode.vim | 150 +++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_visual.vim | 118 +-------------------------- 5 files changed, 157 insertions(+), 157 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index a09346a595..47c9bb87dc 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -262,22 +262,6 @@ func Test_edit_09() bw! endfunc -func Test_edit_10() - " Test for starting selectmode - new - set selectmode=key keymodel=startsel - call setline(1, ['abc', 'def', 'ghi']) - call cursor(1, 4) - call feedkeys("A\start\", 'txin') - call assert_equal(['startdef', 'ghi'], getline(1, '$')) - " start select mode again with gv - set selectmode=cmd - call feedkeys('gvabc', 'xt') - call assert_equal('abctdef', getline(1)) - set selectmode= keymodel= - bw! -endfunc - func Test_edit_11() " Test that indenting kicks in new diff --git a/src/nvim/testdir/test_global.vim b/src/nvim/testdir/test_global.vim index 947f7efc7c..cb6851250c 100644 --- a/src/nvim/testdir/test_global.vim +++ b/src/nvim/testdir/test_global.vim @@ -9,7 +9,10 @@ func Test_yank_put_clipboard() set clipboard=unnamed g/^/normal yyp call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6)) - + set clipboard=unnamed,unnamedplus + call setline(1, ['a', 'b', 'c']) + g/^/normal yyp + call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6)) set clipboard& bwipe! endfunc diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index f125c860d5..347404a579 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -124,31 +124,6 @@ func Test_normal01_keymodel() bw! endfunc -" Test for select mode -func Test_normal02_selectmode() - call Setup_NewWindow() - 50 - norm! gHy - call assert_equal('y51', getline('.')) - call setline(1, range(1,100)) - 50 - exe ":norm! V9jo\y" - call assert_equal('y60', getline('.')) - " clean up - bw! -endfunc - -func Test_normal02_selectmode2() - " some basic select mode tests - call Setup_NewWindow() - 50 - " call feedkeys(":set im\n\gHc\:set noim\n", 'tx') - call feedkeys("i\gHc\", 'tx') - call assert_equal('c51', getline('.')) - " clean up - bw! -endfunc - func Test_normal03_join() " basic join test call Setup_NewWindow() diff --git a/src/nvim/testdir/test_selectmode.vim b/src/nvim/testdir/test_selectmode.vim index b483841060..f2cab45450 100644 --- a/src/nvim/testdir/test_selectmode.vim +++ b/src/nvim/testdir/test_selectmode.vim @@ -2,6 +2,156 @@ source shared.vim +" Test for select mode +func Test_selectmode_basic() + new + call setline(1, range(1,100)) + 50 + norm! gHy + call assert_equal('y51', getline('.')) + call setline(1, range(1,100)) + 50 + exe ":norm! V9jo\y" + call assert_equal('y60', getline('.')) + call setline(1, range(1,100)) + 50 + " call feedkeys(":set im\n\gHc\:set noim\n", 'tx') + call feedkeys("i\gHc\", 'tx') + call assert_equal('c51', getline('.')) + " clean up + bw! +endfunc + +" Test for starting selectmode +func Test_selectmode_start() + new + set selectmode=key keymodel=startsel + call setline(1, ['abc', 'def', 'ghi']) + call cursor(1, 4) + call feedkeys("A\start\", 'txin') + call assert_equal(['startdef', 'ghi'], getline(1, '$')) + " start select mode again with gv + set selectmode=cmd + call feedkeys('gvabc', 'xt') + call assert_equal('abctdef', getline(1)) + set selectmode= keymodel= + bw! +endfunc + +" Test for characterwise select mode +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, '$')) + + " CTRL-H in select mode behaves like 'x' + call setline(1, 'abcdef') + exe "normal! gggh\\\\" + call assert_equal('ef', getline(1)) + + " CTRL-O in select mode switches to visual mode for one command + call setline(1, 'abcdef') + exe "normal! gggh\3lm" + call assert_equal('mef', getline(1)) + + sunmap End> + sunmap Down> + sunmap Del> + bwipe! +endfunc + +" Test for linewise select mode +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 + +" Test for blockwise select mode (g CTRL-H) +func Test_blockwise_select_mode() + new + call setline(1, ['foo', 'bar']) + call feedkeys("g\\\mm", 'xt') + call assert_equal(['mmo', 'mmr'], getline(1, '$')) + close! +endfunc + +" Test for using visual mode maps in select mode +func Test_select_mode_map() + new + vmap 3l + call setline(1, 'Test line') + call feedkeys("gh\map", 'xt') + call assert_equal('map line', getline(1)) + + vmap ygV + call feedkeys("0gh\\\cwabc", 'xt') + call assert_equal('abc line', getline(1)) + + vmap :let v=100 + call feedkeys("gggh\\\foo", 'xt') + call assert_equal('foo line', getline(1)) + + " reselect the select mode using gv from a visual mode map + vmap gv + set selectmode=cmd + call feedkeys("0gh\map", 'xt') + call assert_equal('map line', getline(1)) + set selectmode& + + close! +endfunc + " Test for selecting a register with CTRL-R func Test_selectmode_register() new diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 456f0e0edd..9c1ad0c099 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -664,92 +664,6 @@ func Test_characterwise_visual_mode() 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, '$')) - - " CTRL-H in select mode behaves like 'x' - call setline(1, 'abcdef') - exe "normal! gggh\\\\" - call assert_equal('ef', getline(1)) - - " CTRL-O in select mode switches to visual mode for one command - call setline(1, 'abcdef') - exe "normal! gggh\3lm" - call assert_equal('mef', 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 - -" Test for blockwise select mode (g CTRL-H) -func Test_blockwise_select_mode() - new - call setline(1, ['foo', 'bar']) - call feedkeys("g\\\mm", 'xt') - call assert_equal(['mmo', 'mmr'], getline(1, '$')) - close! -endfunc - func Test_visual_mode_put() new @@ -789,16 +703,16 @@ func Test_visual_mode_put() bwipe! endfunc -func Test_select_mode_gv() +func Test_gv_with_exclusive_selection() new - " gv in exclusive select mode after operation + " gv with exclusive selection after an operation call append('$', ['zzz ', 'äà ']) set selection=exclusive normal Gkv3lyjv3lpgvcxxx call assert_equal(['', 'zzz ', 'xxx '], getline(1, '$')) - " gv in exclusive select mode without operation + " gv with exclusive selection without an operation call deletebufline('', 1, '$') call append('$', 'zzz ') set selection=exclusive @@ -1147,32 +1061,6 @@ func Test_star_register() close! endfunc -" Test for using visual mode maps in select mode -func Test_select_mode_map() - new - vmap 3l - call setline(1, 'Test line') - call feedkeys("gh\map", 'xt') - call assert_equal('map line', getline(1)) - - vmap ygV - call feedkeys("0gh\\\cwabc", 'xt') - call assert_equal('abc line', getline(1)) - - vmap :let v=100 - call feedkeys("gggh\\\foo", 'xt') - call assert_equal('foo line', getline(1)) - - " reselect the select mode using gv from a visual mode map - vmap gv - set selectmode=cmd - call feedkeys("0gh\map", 'xt') - call assert_equal('map line', getline(1)) - set selectmode& - - close! -endfunc - " Test for changing text in visual mode with 'exclusive' selection func Test_exclusive_selection() new -- cgit From b7c86e24f7cc16e642b82a3a157fec06ddc41e51 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Aug 2022 21:40:22 +0800 Subject: vim-patch:8.2.0982: insufficient testing for reading/writing files Problem: Insufficient testing for reading/writing files. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#6257) Add "ui_delay" to test_override() and use it for the CTRL-O test. https://github.com/vim/vim/commit/b340baed9f7fc1c19a0742e2214d54982190c15e Omit test_override(). Reorder test_writefile.vim to match Vim. --- src/nvim/testdir/test_autocmd.vim | 53 ++++++++++++++++ src/nvim/testdir/test_edit.vim | 113 +++++++++++++++++++++++++++++++++- src/nvim/testdir/test_filechanged.vim | 9 +++ src/nvim/testdir/test_writefile.vim | 44 +++++++------ 4 files changed, 199 insertions(+), 20 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 89e3c9927b..716511210d 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2737,6 +2737,59 @@ func Test_autocmd_sigusr1() unlet g:sigusr1_passed endfunc +" Test for BufReadPre autocmd deleting the file +func Test_BufReadPre_delfile() + augroup TestAuCmd + au! + autocmd BufReadPre Xfile call delete('Xfile') + augroup END + call writefile([], 'Xfile') + call assert_fails('new Xfile', 'E200:') + call assert_equal('Xfile', @%) + call assert_equal(1, &readonly) + call delete('Xfile') + augroup TestAuCmd + au! + augroup END + close! +endfunc + +" Test for BufReadPre autocmd changing the current buffer +func Test_BufReadPre_changebuf() + augroup TestAuCmd + au! + autocmd BufReadPre Xfile edit Xsomeotherfile + augroup END + call writefile([], 'Xfile') + call assert_fails('new Xfile', 'E201:') + call assert_equal('Xsomeotherfile', @%) + call assert_equal(1, &readonly) + call delete('Xfile') + augroup TestAuCmd + au! + augroup END + close! +endfunc + +" Test for BufWipeouti autocmd changing the current buffer when reading a file +" in an empty buffer with 'f' flag in 'cpo' +func Test_BufDelete_changebuf() + new + augroup TestAuCmd + au! + autocmd BufWipeout * let bufnr = bufadd('somefile') | exe "b " .. bufnr + augroup END + let save_cpo = &cpo + set cpo+=f + call assert_fails('r Xfile', 'E484:') + call assert_equal('somefile', @%) + let &cpo = save_cpo + augroup TestAuCmd + au! + augroup END + close! +endfunc + " Test for the temporary internal window used to execute autocmds func Test_autocmd_window() %bw! diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 47c9bb87dc..e26bbdc5be 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1604,6 +1604,7 @@ func Test_edit_InsertLeave_undo() bwipe! au! InsertLeave call delete('XtestUndo') + call delete(undofile('XtestUndo')) set undofile& endfunc @@ -1671,11 +1672,11 @@ func Test_edit_noesckeys() endfunc " Test for running an invalid ex command in insert mode using CTRL-O -" Note that vim has a hard-coded sleep of 3 seconds. So this test will take -" more than 3 seconds to complete. func Test_edit_ctrl_o_invalid_cmd() new set showmode showcmd + " Avoid a sleep of 3 seconds. Zero might have side effects. + " call test_override('ui_delay', 50) let caught_e492 = 0 try call feedkeys("i\:invalid\abc\", "xt") @@ -1685,6 +1686,18 @@ func Test_edit_ctrl_o_invalid_cmd() call assert_equal(1, caught_e492) call assert_equal('abc', getline(1)) set showmode& showcmd& + " call test_override('ui_delay', 0) + close! +endfunc + +" Test for editing a file with a very long name +func Test_edit_illegal_filename() + CheckEnglish + new + redir => msg + exe 'edit ' . repeat('f', 5000) + redir END + call assert_match("Illegal file name$", split(msg, "\n")[0]) close! endfunc @@ -1747,6 +1760,102 @@ func Test_edit_is_a_directory() call delete(dirname, 'rf') endfunc +" Test for editing a file using invalid file encoding +func Test_edit_invalid_encoding() + CheckEnglish + call writefile([], 'Xfile') + redir => msg + new ++enc=axbyc Xfile + redir END + call assert_match('\[NOT converted\]', msg) + call delete('Xfile') + close! +endfunc + +" Test for the "charconvert" option +func Test_edit_charconvert() + CheckEnglish + call writefile(['one', 'two'], 'Xfile') + + " set 'charconvert' to a non-existing function + set charconvert=NonExitingFunc() + new + let caught_e117 = v:false + try + redir => msg + edit ++enc=axbyc Xfile + catch /E117:/ + let caught_e117 = v:true + finally + redir END + endtry + call assert_true(caught_e117) + call assert_equal(['one', 'two'], getline(1, '$')) + call assert_match("Conversion with 'charconvert' failed", msg) + close! + set charconvert& + + " 'charconvert' function doesn't create a output file + func Cconv1() + endfunc + set charconvert=Cconv1() + new + redir => msg + edit ++enc=axbyc Xfile + redir END + call assert_equal(['one', 'two'], getline(1, '$')) + call assert_match("can't read output of 'charconvert'", msg) + close! + delfunc Cconv1 + set charconvert& + + " 'charconvert' function to convert to upper case + func Cconv2() + let data = readfile(v:fname_in) + call map(data, 'toupper(v:val)') + call writefile(data, v:fname_out) + endfunc + set charconvert=Cconv2() + new Xfile + write ++enc=ucase Xfile1 + call assert_equal(['ONE', 'TWO'], readfile('Xfile1')) + call delete('Xfile1') + close! + delfunc Cconv2 + set charconvert& + + " 'charconvert' function removes the input file + func Cconv3() + call delete(v:fname_in) + endfunc + set charconvert=Cconv3() + new + call assert_fails('edit ++enc=lcase Xfile', 'E202:') + call assert_equal([''], getline(1, '$')) + close! + delfunc Cconv3 + set charconvert& + + call delete('Xfile') +endfunc + +" Test for editing a file without read permission +func Test_edit_file_no_read_perm() + CheckUnix + CheckNotBSD + call writefile(['one', 'two'], 'Xfile') + call setfperm('Xfile', '-w-------') + new + redir => msg + edit Xfile + redir END + call assert_equal(1, &readonly) + call assert_equal([''], getline(1, '$')) + call assert_match('\[Permission Denied\]', msg) + close! + call delete('Xfile') +endfunc + " Using :edit without leaving 'insertmode' should not cause Insert mode to be " re-entered immediately after func Test_edit_insertmode_ex_edit() diff --git a/src/nvim/testdir/test_filechanged.vim b/src/nvim/testdir/test_filechanged.vim index c6e781a1ef..b77f02afd1 100644 --- a/src/nvim/testdir/test_filechanged.vim +++ b/src/nvim/testdir/test_filechanged.vim @@ -242,6 +242,15 @@ func Test_file_changed_dialog() call assert_equal(1, line('$')) call assert_equal('new line', getline(1)) + " File created after starting to edit it + call delete('Xchanged_d') + new Xchanged_d + call writefile(['one'], 'Xchanged_d') + call feedkeys('L', 'L') + checktime Xchanged_d + call assert_equal(['one'], getline(1, '$')) + close! + bwipe! call delete('Xchanged_d') endfunc diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index bfbba1f793..a8735bcaf1 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -128,6 +128,25 @@ func Test_nowrite_quit_split() bwipe Xfile endfunc +func Test_writefile_sync_arg() + " This doesn't check if fsync() works, only that the argument is accepted. + call writefile(['one'], 'Xtest', 's') + call writefile(['two'], 'Xtest', 'S') + call delete('Xtest') +endfunc + +func Test_writefile_sync_dev_stdout() + if !has('unix') + return + endif + if filewritable('/dev/stdout') + " Just check that this doesn't cause an error. + call writefile(['one'], '/dev/stdout', 's') + else + throw 'Skipped: /dev/stdout is not writable' + endif +endfunc + func Test_writefile_autowrite() set autowrite new @@ -237,29 +256,18 @@ func Test_write_errors() call delete('Xfile') endfunc -func Test_writefile_sync_dev_stdout() - if !has('unix') - return - endif - if filewritable('/dev/stdout') - " Just check that this doesn't cause an error. - call writefile(['one'], '/dev/stdout', 's') - else - throw 'Skipped: /dev/stdout is not writable' - endif -endfunc - -func Test_writefile_sync_arg() - " This doesn't check if fsync() works, only that the argument is accepted. - call writefile(['one'], 'Xtest', 's') - call writefile(['two'], 'Xtest', 'S') - call delete('Xtest') +" Test for writing a file using invalid file encoding +func Test_write_invalid_encoding() + new + call setline(1, 'abc') + call assert_fails('write ++enc=axbyc Xfile', 'E213:') + close! endfunc " Tests for reading and writing files with conversion for Win32. func Test_write_file_encoding() - CheckMSWindows throw 'skipped: Nvim does not support :w ++enc=cp1251' + CheckMSWindows let save_encoding = &encoding let save_fileencodings = &fileencodings set encoding& fileencodings& -- cgit