From 9671908c682dc3fc4e939f44a636457db6f3e5a4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 3 Dec 2022 08:17:38 +0800 Subject: vim-patch:8.2.3900: it is not easy to use a script-local function for an option Problem: It is not easy to use a script-local function for an option. Solution: recognize s: and at the start of the expression. (Yegappan Lakshmanan, closes vim/vim#9401) https://github.com/vim/vim/commit/8bb65f230d3025037f34021a72616038da0601ee Omit duplicate docs in fold.txt: removed in a later runtime update. Cherry-pick test_diffmode.vim changes from patch 8.2.1432. Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_fold.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/nvim/testdir/test_fold.vim') diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index 2215166cd6..bc8364a80e 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -1273,6 +1273,32 @@ func Test_fold_jump() bw! endfunc +" Test for using a script-local function for 'foldexpr' +func Test_foldexpr_scriptlocal_func() + func! s:FoldFunc() + let g:FoldLnum = v:lnum + endfunc + new | only + call setline(1, 'abc') + let g:FoldLnum = 0 + set foldmethod=expr foldexpr=s:FoldFunc() + redraw! + call assert_equal(expand('') .. 'FoldFunc()', &foldexpr) + call assert_equal(1, g:FoldLnum) + set foldmethod& foldexpr= + bw! + new | only + call setline(1, 'abc') + let g:FoldLnum = 0 + set foldmethod=expr foldexpr=FoldFunc() + redraw! + call assert_equal(expand('') .. 'FoldFunc()', &foldexpr) + call assert_equal(1, g:FoldLnum) + set foldmethod& foldexpr= + delfunc s:FoldFunc + bw! +endfunc + " Make sure a fold containing a nested fold is split correctly when using " foldmethod=indent func Test_fold_split() -- cgit From 5e97984188e95de419ba5a710a060f0614c6c9e0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 3 Dec 2022 08:37:10 +0800 Subject: vim-patch:partial:8.2.3908: cannot use a script-local function for 'foldtext' Problem: Cannot use a script-local function for 'foldtext'. Solution: Expand "s:" and "". (Yegappan Lakshmanan, closes vim/vim#9411) https://github.com/vim/vim/commit/27708e6c7b6f444fd599f3dc5015336b002b874d Only port the changes actually related to 'foldtext'. Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_fold.vim | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/nvim/testdir/test_fold.vim') diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index bc8364a80e..d74187537c 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -1299,6 +1299,37 @@ func Test_foldexpr_scriptlocal_func() 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 + " Make sure a fold containing a nested fold is split correctly when using " foldmethod=indent func Test_fold_split() -- cgit