To: vim_dev@googlegroups.com Subject: Patch 8.2.3908 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3908 Problem: Cannot use a script-local function for 'foldtext'. Solution: Expand "s:" and "". (Yegappan Lakshmanan, closes #9411) Files: runtime/doc/fold.txt, src/optionstr.c, src/strings.c, src/testdir/test_blob.vim, src/testdir/test_expr.vim, src/testdir/test_filter_map.vim, src/testdir/test_fold.vim, src/testdir/test_listdict.vim *** ../vim-8.2.3907/runtime/doc/fold.txt 2021-12-26 10:51:33.707079472 +0000 --- runtime/doc/fold.txt 2021-12-26 21:43:57.813021824 +0000 *************** *** 122,128 **** backwards for a line for which the fold level is defined. This can be slow. If the 'foldexpr' expression starts with s: or ||, then it is replaced ! with the script ID (|local-function|). Example: > set foldexpr=s:MyFoldExpr() set foldexpr=SomeFoldExpr() < --- 122,128 ---- backwards for a line for which the fold level is defined. This can be slow. If the 'foldexpr' expression starts with s: or ||, then it is replaced ! with the script ID (|local-function|). Examples: > set foldexpr=s:MyFoldExpr() set foldexpr=SomeFoldExpr() < *************** *** 529,534 **** --- 529,539 ---- When there is room after the text, it is filled with the character specified by 'fillchars'. + If the 'foldtext' expression starts with s: or ||, then it is replaced + with the script ID (|local-function|). Examples: > + set foldtext=s:MyFoldText() + set foldtext=SomeFoldText() + < Note that backslashes need to be used for characters that the ":set" command handles differently: Space, backslash and double-quote. |option-backslash| *** ../vim-8.2.3907/src/optionstr.c 2021-12-26 10:51:33.711079465 +0000 --- src/optionstr.c 2021-12-26 21:47:53.352815641 +0000 *************** *** 2310,2315 **** --- 2310,2316 ---- # endif # ifdef FEAT_FOLDING varp == &curwin->w_p_fde || + varp == &curwin->w_p_fdt || # endif gvarp == &p_fex || # ifdef FEAT_FIND_ID *************** *** 2341,2348 **** p_opt = &p_dex; # endif # ifdef FEAT_FOLDING ! if(varp == &curwin->w_p_fde) // 'foldexpr' p_opt = &curwin->w_p_fde; # endif if (gvarp == &p_fex) // 'formatexpr' p_opt = &curbuf->b_p_fex; --- 2342,2351 ---- p_opt = &p_dex; # endif # ifdef FEAT_FOLDING ! if (varp == &curwin->w_p_fde) // 'foldexpr' p_opt = &curwin->w_p_fde; + if (varp == &curwin->w_p_fdt) // 'foldtext' + p_opt = &curwin->w_p_fdt; # endif if (gvarp == &p_fex) // 'formatexpr' p_opt = &curbuf->b_p_fex; *** ../vim-8.2.3907/src/strings.c 2021-12-22 18:19:22.602372473 +0000 --- src/strings.c 2021-12-26 21:43:57.813021824 +0000 *************** *** 905,912 **** set_vim_var_nr(VV_KEY, idx); if (filter_map_one(&tv, expr, filtermap, &newtv, &rem) == FAIL || did_emsg) - break; - if (did_emsg) { clear_tv(&newtv); clear_tv(&tv); --- 905,910 ---- *** ../vim-8.2.3907/src/testdir/test_blob.vim 2021-12-19 19:19:27.818424761 +0000 --- src/testdir/test_blob.vim 2021-12-26 21:43:57.813021824 +0000 *************** *** 37,42 **** --- 37,43 ---- call assert_fails('VAR b = 0z001122.') call assert_fails('call get("", 1)', 'E896:') call assert_equal(0, len(test_null_blob())) + call assert_equal(0z, copy(test_null_blob())) END call CheckLegacyAndVim9Success(lines) endfunc *************** *** 369,374 **** --- 370,383 ---- add(test_null_blob(), 0x22) END call CheckDefExecAndScriptFailure(lines, 'E1131:') + + let lines =<< trim END + let b = 0zDEADBEEF + lockvar b + call add(b, 0) + unlockvar b + END + call CheckScriptFailure(lines, 'E741:') endfunc func Test_blob_empty() *************** *** 445,450 **** --- 454,462 ---- remove(b, 0) END call CheckScriptFailure(lines, 'E741:') + + call assert_fails('echo remove(0z1020, [])', 'E745:') + call assert_fails('echo remove(0z1020, 0, [])', 'E745:') endfunc func Test_blob_read_write() *************** *** 474,479 **** --- 486,492 ---- call assert_equal(0zADEF, filter(0zDEADBEEF, 'v:key % 2')) END call CheckLegacyAndVim9Success(lines) + call assert_fails('echo filter(0z10, "a10")', 'E121:') endfunc " map() item in blob *************** *** 489,494 **** --- 502,508 ---- call map(0z00, '[9]') END call CheckLegacyAndVim9Failure(lines, 'E978:') + call assert_fails('echo map(0z10, "a10")', 'E121:') endfunc func Test_blob_index() *** ../vim-8.2.3907/src/testdir/test_expr.vim 2021-12-24 20:47:34.748104242 +0000 --- src/testdir/test_expr.vim 2021-12-26 21:43:57.813021824 +0000 *************** *** 405,410 **** --- 405,411 ---- call assert_equal('[00000あiう]', printf('[%010.7S]', 'あiう')) call assert_equal('1%', printf('%d%%', 1)) + call assert_notequal('', printf('%p', "abc")) END call CheckLegacyAndVim9Success(lines) *** ../vim-8.2.3907/src/testdir/test_filter_map.vim 2021-12-22 18:19:22.602372473 +0000 --- src/testdir/test_filter_map.vim 2021-12-26 21:43:57.813021824 +0000 *************** *** 183,188 **** --- 183,189 ---- call assert_equal('', map('', "v:val == 'a'")) call assert_equal('', map(test_null_string(), "v:val == 'a'")) call assert_fails('echo map("abc", "10")', 'E928:') + call assert_fails('echo map("abc", "a10")', 'E121:') END call CheckLegacyAndVim9Success(lines) *** ../vim-8.2.3907/src/testdir/test_fold.vim 2021-12-26 10:51:33.711079465 +0000 --- src/testdir/test_fold.vim 2021-12-26 21:43:57.813021824 +0000 *************** *** 1408,1411 **** --- 1408,1442 ---- bw! endfunc + " Test for using a script-local function for 'foldtext' + func Test_foldtext_scriptlocal_func() + func! s:FoldText() + let g:FoldTextArgs = [v:foldstart, v:foldend] + return foldtext() + endfunc + new | only + call setline(1, range(50)) + let g:FoldTextArgs = [] + set foldmethod=manual + set foldtext=s:FoldText() + norm! 4Gzf4j + redraw! + call assert_equal(expand('') .. 'FoldText()', &foldtext) + call assert_equal([4, 8], g:FoldTextArgs) + set foldtext& + bw! + new | only + call setline(1, range(50)) + let g:FoldTextArgs = [] + set foldmethod=manual + set foldtext=FoldText() + norm! 8Gzf4j + redraw! + call assert_equal(expand('') .. 'FoldText()', &foldtext) + call assert_equal([8, 12], g:FoldTextArgs) + set foldtext& + bw! + delfunc s:FoldText + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3907/src/testdir/test_listdict.vim 2021-12-22 18:19:22.602372473 +0000 --- src/testdir/test_listdict.vim 2021-12-26 21:43:57.813021824 +0000 *************** *** 1163,1168 **** --- 1163,1169 ---- let d = {'a': 'A', 'b': 'B'} call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:') + call assert_fails("call extend(d, {'b': 0}, [])", 'E730:') call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:') if has('float') call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E475:') *** ../vim-8.2.3907/src/version.c 2021-12-26 20:20:29.097631222 +0000 --- src/version.c 2021-12-26 21:45:56.388920110 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3908, /**/ -- hundred-and-one symptoms of being an internet addict: 117. You are more comfortable typing in html. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///