From 83ef740e150c5f29bd8ed92681d892160474fd7f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 20 Jun 2019 22:05:29 -0400 Subject: vim-patch:8.0.1239: cannot use a lambda for the skip argument to searchpair() Problem: Cannot use a lambda for the skip argument to searchpair(). Solution: Evaluate a partial, funcref and lambda. (LemonBoy, closes vim/vim#1454, closes vim/vim#2265) https://github.com/vim/vim/commit/48570488f17e397183ea7d5c7ca67d6e4ffb013d --- src/nvim/testdir/test_search.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 87cad241e2..24ea8cd75a 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -298,6 +298,25 @@ func Test_searchpair() q! endfunc +func Test_searchpair_skip() + func Zero() + return 0 + endfunc + func Partial(x) + return a:x + endfunc + new + call setline(1, ['{', 'foo', 'foo', 'foo', '}']) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', '')) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', '0')) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', {-> 0})) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Zero'))) + 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Partial', [0]))) + " invalid argument + 3 | call assert_equal(0, searchpair('{', '', '}', 'bWn', 0)) + bw! +endfunc + func Test_searchc() " These commands used to cause memory overflow in searchc(). new -- cgit From efdc0f6a6949ec9bfb0d9ef454871458489773f0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 21 Jun 2019 07:38:43 -0400 Subject: vim-patch:8.1.0112: no error when using bad arguments with searchpair() Problem: No error when using bad arguments with searchpair(). Solution: Add error messages. https://github.com/vim/vim/commit/3dddb09c98825acefa6f2d94bb369b8e00d7b3e5 --- src/nvim/testdir/test_search.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 24ea8cd75a..c455279a59 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -288,16 +288,26 @@ func Test_searchpair() new call setline(1, ['other code here', '', '[', '" cursor here', ']']) 4 - let a=searchpair('\[','',']','bW') + let a = searchpair('\[','',']','bW') call assert_equal(3, a) set nomagic 4 - let a=searchpair('\[','',']','bW') + let a = searchpair('\[','',']','bW') call assert_equal(3, a) set magic q! endfunc +func Test_searchpair_errors() + call assert_fails("call searchpair([0], 'middle', 'end', 'bW', 'skip', 99, 100)", 'E730: using List as a String') + call assert_fails("call searchpair('start', {-> 0}, 'end', 'bW', 'skip', 99, 100)", 'E729: using Funcref as a String') + call assert_fails("call searchpair('start', 'middle', {'one': 1}, 'bW', 'skip', 99, 100)", 'E731: using Dictionary as a String') + call assert_fails("call searchpair('start', 'middle', 'end', 'flags', 'skip', 99, 100)", 'E475: Invalid argument: flags') + call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 0, 99, 100)", 'E475: Invalid argument: 0') + call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', -99, 100)", 'E475: Invalid argument: -99') + call assert_fails("call searchpair('start', 'middle', 'end', 'bW', 'func', 99, -100)", 'E475: Invalid argument: -100') +endfunc + func Test_searchpair_skip() func Zero() return 0 @@ -312,8 +322,6 @@ func Test_searchpair_skip() 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', {-> 0})) 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Zero'))) 3 | call assert_equal(1, searchpair('{', '', '}', 'bWn', function('Partial', [0]))) - " invalid argument - 3 | call assert_equal(0, searchpair('{', '', '}', 'bWn', 0)) bw! endfunc -- cgit From f0d6695e7cc13cd5f1ee006575a369faf2546893 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 21 Jun 2019 20:46:43 -0400 Subject: vim-patch:8.1.0181: memory leak with trailing characters in skip expression Problem: Memory leak with trailing characters in skip expression. Solution: Free the return value. https://github.com/vim/vim/commit/a43ebe9454386427ca38c75810e2d36991f17812 --- src/nvim/testdir/test_search.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index c455279a59..5e5ec96fd1 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -325,6 +325,16 @@ func Test_searchpair_skip() bw! endfunc +func Test_searchpair_leak() + new + call setline(1, 'if one else another endif') + + " The error in the skip expression caused memory to leak. + call assert_fails("call searchpair('\\', '\\', '\\', '', '\"foo\" 2')", 'E15:') + + bwipe! +endfunc + func Test_searchc() " These commands used to cause memory overflow in searchc(). new -- cgit From 3abffe7015701f2468f94af3280871cd34653747 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 21 Jun 2019 21:29:21 -0400 Subject: vim-patch:8.1.0125: virtual edit replace with multi-byte fails at end of line Problem: Virtual edit replace with multi-byte fails at end of line. (Lukas Werling) Solution: use ins_char() to add the character. (Christian Brabandt, closes vim/vim#3114) Rename PCHAR() to PBYTE() to avoid mistakes like this. https://github.com/vim/vim/commit/630afe889a2a02b367ea8eaaa48e66ed81e77ff3 --- src/nvim/testdir/test_virtualedit.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_virtualedit.vim b/src/nvim/testdir/test_virtualedit.vim index d49025237b..abe79f6a4a 100644 --- a/src/nvim/testdir/test_virtualedit.vim +++ b/src/nvim/testdir/test_virtualedit.vim @@ -42,6 +42,22 @@ func Test_paste_end_of_line() set virtualedit= endfunc +func Test_replace_end_of_line() + new + set virtualedit=all + call setline(1, range(20)) + exe "normal! gg2jv10lr-" + call assert_equal(["1", "-----------", "3"], getline(2,4)) + if has('multi_byte') + call setline(1, range(20)) + exe "normal! gg2jv10lr\hh" + call assert_equal(["1", "───────────", "3"], getline(2,4)) + endif + + bwipe! + set virtualedit= +endfunc + func Test_edit_CTRL_G() new set virtualedit=insert -- cgit From ff244a1309482e818c6731038f0232fae613431c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 21 Jun 2019 22:44:33 -0400 Subject: vim-patch:8.1.0165: :clist output can be very long Problem: :clist output can be very long. Solution: Support filtering :clist entries. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/4cde86c2ef885e82fff3d925dee9fb5671c025cf --- src/nvim/testdir/test_quickfix.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 4d78c67f5c..ce0b8f1be8 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3373,6 +3373,23 @@ func Test_lbuffer_with_bwipe() augroup END endfunc +" Tests for the ':filter /pat/ clist' command +func Test_filter_clist() + cexpr ['Xfile1:10:10:Line 10', 'Xfile2:15:15:Line 15'] + call assert_equal([' 2 Xfile2:15 col 15: Line 15'], + \ split(execute('filter /Line 15/ clist'), "\n")) + call assert_equal([' 1 Xfile1:10 col 10: Line 10'], + \ split(execute('filter /Xfile1/ clist'), "\n")) + call assert_equal([], split(execute('filter /abc/ clist'), "\n")) + + call setqflist([{'module' : 'abc', 'pattern' : 'pat1'}, + \ {'module' : 'pqr', 'pattern' : 'pat2'}], ' ') + call assert_equal([' 2 pqr:pat2: '], + \ split(execute('filter /pqr/ clist'), "\n")) + call assert_equal([' 1 abc:pat1: '], + \ split(execute('filter /pat1/ clist'), "\n")) +endfunc + func Test_setloclist_in_aucmd() " This was using freed memory. augroup nasty -- cgit From 25f99dde9480bcfa32f172c0032a2d24d7c32153 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 22 Jun 2019 11:41:41 -0400 Subject: vim-patch:8.1.0272: options test fails if temp var ends in slash Problem: Options test fails if temp var ends in slash. (Tom Briden) Solution: Check for optional slash. (closes vim/vim#3308) https://github.com/vim/vim/commit/f53c692240851f71b930e80a0b0b5d4cfcc1b4a3 --- src/nvim/testdir/test_options.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index da87a22f1e..9aa003f475 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -357,7 +357,7 @@ func Test_backupskip() for var in ['$TEMPDIR', '$TMP', '$TEMP'] if exists(var) let varvalue = substitute(expand(var), '\\', '/', 'g') - call assert_match(varvalue . '.\*', bskvalue) + call assert_match(varvalue . '/\=\*', bskvalue) endif endfor endfunc -- cgit From ca6b42d7fdb4e533e7875b1ed23e4a07b900b09d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 22 Jun 2019 14:55:25 -0400 Subject: vim-patch:8.1.0850: test for 'backupskip' is not correct Problem: Test for 'backupskip' is not correct. Solution: Split the option in parts and use expand(). (Michael Soyka) https://github.com/vim/vim/commit/98ad1e17c3f71962862f959c6ba57dd01e8a83c2 --- src/nvim/testdir/test_options.vim | 45 ++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 9aa003f475..eedf8c23c4 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -92,9 +92,6 @@ function! Test_path_keep_commas() endfunction func Test_filetype_valid() - if !has('autocmd') - return - endif set ft=valid_name call assert_equal("valid_name", &filetype) set ft=valid-name @@ -347,17 +344,49 @@ func Test_set_indentexpr() endfunc func Test_backupskip() + " Option 'backupskip' may contain several comma-separated path + " specifications if one or more of the environment variables TMPDIR, TMP, + " or TEMP is defined. To simplify testing, convert the string value into a + " list. + let bsklist = split(&bsk, ',') + if has("mac") - call assert_match('/private/tmp/\*', &bsk) + let found = (index(bsklist, '/private/tmp/*') >= 0) + call assert_true(found, '/private/tmp not in option bsk: ' . &bsk) elseif has("unix") - call assert_match('/tmp/\*', &bsk) + let found = (index(bsklist, '/tmp/*') >= 0) + call assert_true(found, '/tmp not in option bsk: ' . &bsk) + endif + + " If our test platform is Windows, the path(s) in option bsk will use + " backslash for the path separator and the components could be in short + " (8.3) format. As such, we need to replace the backslashes with forward + " slashes and convert the path components to long format. The expand() + " function will do this but it cannot handle comma-separated paths. This is + " why bsk was converted from a string into a list of strings above. + " + " One final complication is that the wildcard "/*" is at the end of each + " path and so expand() might return a list of matching files. To prevent + " this, we need to remove the wildcard before calling expand() and then + " append it afterwards. + if has('win32') + let item_nbr = 0 + while item_nbr < len(bsklist) + let path_spec = bsklist[item_nbr] + let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2) + let path_spec = substitute(expand(path_spec), '\\', '/', 'g') + let bsklist[item_nbr] = path_spec . '/*' + let item_nbr += 1 + endwhile endif - let bskvalue = substitute(&bsk, '\\', '/', 'g') - for var in ['$TEMPDIR', '$TMP', '$TEMP'] + " Option bsk will also include these environment variables if defined. + " If they're defined, verify they appear in the option value. + for var in ['$TMPDIR', '$TMP', '$TEMP'] if exists(var) let varvalue = substitute(expand(var), '\\', '/', 'g') - call assert_match(varvalue . '/\=\*', bskvalue) + let found = (index(bsklist, varvalue.'/*') >= 0) + call assert_true(found, var . ' not in option bsk: ' . &bsk) endif endfor endfunc -- cgit From 6558e02b95d94a8be60757cc39df227836ec1f9c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 22 Jun 2019 14:56:53 -0400 Subject: vim-patch:8.1.0853: options test fails on Mac Problem: Options test fails on Mac. Solution: Remove a trailing slash from $TMPDIR. https://github.com/vim/vim/commit/cbbd0f657803a9a3a9f5e2c66bce6e1ea1d6a64b --- src/nvim/testdir/test_options.vim | 6 ++++-- 1 file changed, 4 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 eedf8c23c4..ecfc84432a 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -385,8 +385,10 @@ func Test_backupskip() for var in ['$TMPDIR', '$TMP', '$TEMP'] if exists(var) let varvalue = substitute(expand(var), '\\', '/', 'g') - let found = (index(bsklist, varvalue.'/*') >= 0) - call assert_true(found, var . ' not in option bsk: ' . &bsk) + let varvalue = substitute(varvalue, '/$', '', '') + let varvalue .= '/*' + let found = (index(bsklist, varvalue) >= 0) + call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' . &bsk) endif endfor endfunc -- cgit From 2813c83ea10b157974bdff7ceec9c3fc7f0d3380 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 22 Jun 2019 15:19:01 -0400 Subject: vim-patch:8.1.1519: 'backupskip' may contain duplicates Problem: 'backupskip' may contain duplicates. Solution: Add the P_NODUP flag. (Tom Ryder) https://github.com/vim/vim/commit/06e2c81f6d213d197aa60019b33a263cd5176d68 --- src/nvim/testdir/test_options.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index ecfc84432a..28576709a3 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -391,6 +391,15 @@ func Test_backupskip() call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' . &bsk) endif endfor + + " Duplicates should be filtered out (option has P_NODUP) + let backupskip = &backupskip + set backupskip= + set backupskip+=/test/dir + set backupskip+=/other/dir + set backupskip+=/test/dir + call assert_equal('/test/dir,/other/dir', &backupskip) + let &backupskip = backupskip endfunc func Test_copy_winopt() -- cgit From 4653b5943f2ccdb65fa1e099853d4d680abc3f83 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 22 Jun 2019 19:40:12 -0400 Subject: vim-patch:8.1.0747: map() with a bad expression doesn't give an error Problem: map() with a bad expression doesn't give an error. (Ingo Karkat) Solution: Check for giving an error message. (closes vim/vim#3800) https://github.com/vim/vim/commit/ce9d50df07402cb8e196537a9c4505845adecabc --- src/nvim/testdir/test_filter_map.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_filter_map.vim b/src/nvim/testdir/test_filter_map.vim index c8d64ce0a4..1dd3a5b29f 100644 --- a/src/nvim/testdir/test_filter_map.vim +++ b/src/nvim/testdir/test_filter_map.vim @@ -79,3 +79,8 @@ func Test_filter_map_dict_expr_funcref() endfunc call assert_equal({"foo": "f", "bar": "b", "baz": "b"}, map(copy(dict), function('s:filter4'))) endfunc + +func Test_map_fails() + call assert_fails('call map([1], "42 +")', 'E15:') + call assert_fails('call filter([1], "42 +")', 'E15:') +endfunc -- cgit