Mercurial > vim
diff src/testdir/test_fold.vim @ 26743:c2c40cefc17b v8.2.3900
patch 8.2.3900: it is not easy to use a script-local function for an option
Commit: https://github.com/vim/vim/commit/8bb65f230d3025037f34021a72616038da0601ee
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sun Dec 26 10:51:39 2021 +0000
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 #9401)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Dec 2021 12:00:04 +0100 |
parents | eab30779c97c |
children | 31c23760d590 |
line wrap: on
line diff
--- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -1382,4 +1382,30 @@ 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 + " vim: shiftwidth=2 sts=2 expandtab