diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-12-26 10:51:39 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-26 10:51:39 +0000 |
commit | 8bb65f230d3025037f34021a72616038da0601ee (patch) | |
tree | 1edaf57b7fbe5e3c30a174026f5389f8b98b7376 /src/testdir/test_normal.vim | |
parent | ec86520f946a40d5c4a92d6a11d6928faa13abd4 (diff) |
patch 8.2.3900: it is not easy to use a script-local function for an optionv8.2.3900
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)
Diffstat (limited to 'src/testdir/test_normal.vim')
-rw-r--r-- | src/testdir/test_normal.vim | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 57ea6d3ecc..6458a1bed4 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -253,6 +253,45 @@ func Test_normal_formatexpr_returns_nonzero() close! endfunc +" Test for using a script-local function for 'formatexpr' +func Test_formatexpr_scriptlocal_func() + func! s:Format() + let g:FormatArgs = [v:lnum, v:count] + endfunc + set formatexpr=s:Format() + call assert_equal(expand('<SID>') .. 'Format()', &formatexpr) + new | only + call setline(1, range(1, 40)) + let g:FormatArgs = [] + normal! 2GVjgq + call assert_equal([2, 2], g:FormatArgs) + bw! + set formatexpr=<SID>Format() + call assert_equal(expand('<SID>') .. 'Format()', &formatexpr) + new | only + call setline(1, range(1, 40)) + let g:FormatArgs = [] + normal! 4GVjgq + call assert_equal([4, 2], g:FormatArgs) + bw! + let &formatexpr = 's:Format()' + new | only + call setline(1, range(1, 40)) + let g:FormatArgs = [] + normal! 6GVjgq + call assert_equal([6, 2], g:FormatArgs) + bw! + let &formatexpr = '<SID>Format()' + new | only + call setline(1, range(1, 40)) + let g:FormatArgs = [] + normal! 8GVjgq + call assert_equal([8, 2], g:FormatArgs) + setlocal formatexpr= + delfunc s:Format + bw! +endfunc + " basic test for formatprg func Test_normal06_formatprg() " only test on non windows platform |