diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-03 08:37:10 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-12-03 08:39:57 +0800 |
commit | 5e97984188e95de419ba5a710a060f0614c6c9e0 (patch) | |
tree | be47cfc360ca4f467228d2c900fe5202bd6693a5 /src | |
parent | 9671908c682dc3fc4e939f44a636457db6f3e5a4 (diff) | |
download | rneovim-5e97984188e95de419ba5a710a060f0614c6c9e0.tar.gz rneovim-5e97984188e95de419ba5a710a060f0614c6c9e0.tar.bz2 rneovim-5e97984188e95de419ba5a710a060f0614c6c9e0.zip |
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 "<SID>". (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 <yegappan@yahoo.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/optionstr.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_fold.vim | 31 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index b5dce7ff2a..cd87db9aa9 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -1483,6 +1483,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf } } else if (varp == &p_dex || varp == &curwin->w_p_fde + || varp == &curwin->w_p_fdt || gvarp == &p_fex || gvarp == &p_inex || gvarp == &p_inde @@ -1499,6 +1500,9 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf 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; + } if (gvarp == &p_fex) { // 'formatexpr' p_opt = &curbuf->b_p_fex; } 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('<SID>') .. '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=<SID>FoldText() + norm! 8Gzf4j + redraw! + call assert_equal(expand('<SID>') .. '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() |