aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_fold.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-03 08:17:38 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-03 08:35:13 +0800
commit9671908c682dc3fc4e939f44a636457db6f3e5a4 (patch)
treecc8180e5890f33950be616471ec521b0f08dc5a4 /src/nvim/testdir/test_fold.vim
parent2ae0d32a72c3ee207b6f9cd48c4beffa6e7c774f (diff)
downloadrneovim-9671908c682dc3fc4e939f44a636457db6f3e5a4.tar.gz
rneovim-9671908c682dc3fc4e939f44a636457db6f3e5a4.tar.bz2
rneovim-9671908c682dc3fc4e939f44a636457db6f3e5a4.zip
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 <SID> 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 <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/testdir/test_fold.vim')
-rw-r--r--src/nvim/testdir/test_fold.vim26
1 files changed, 26 insertions, 0 deletions
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('<SID>') .. '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=<SID>FoldFunc()
+ redraw!
+ call assert_equal(expand('<SID>') .. '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()