aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-08-01 10:13:45 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-08-02 11:56:51 +0800
commitf7fde0173af95925e7324b7d3c09776173dab8a7 (patch)
treec7a54472837afe4baf13e66855265cc8a003805a /test
parent48e4589eaded3213956aa9ddbcc0aa6971a974e5 (diff)
downloadrneovim-f7fde0173af95925e7324b7d3c09776173dab8a7.tar.gz
rneovim-f7fde0173af95925e7324b7d3c09776173dab8a7.tar.bz2
rneovim-f7fde0173af95925e7324b7d3c09776173dab8a7.zip
vim-patch:9.0.0632: calling a function from an "expr" option has overhead
Problem: Calling a function from an "expr" option has too much overhead. Solution: Add call_simple_func() and use it for 'foldexpr' https://github.com/vim/vim/commit/87b4e5c5db9d1cfd6f2e79656e1a6cff3c69d15f Cherry-pick a call_func() change from patch 8.2.1343. Add expr-option-function docs to options.txt. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_fold.vim26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/old/testdir/test_fold.vim b/test/old/testdir/test_fold.vim
index 36f72f5e01..a0eb3afdbb 100644
--- a/test/old/testdir/test_fold.vim
+++ b/test/old/testdir/test_fold.vim
@@ -386,6 +386,32 @@ func Test_foldexpr_no_interrupt_addsub()
set foldmethod& foldexpr&
endfunc
+" Fold function defined in another script
+func Test_foldexpr_compiled()
+ throw 'Skipped: Vim9 script is N/A'
+ new
+ let lines =<< trim END
+ vim9script
+ def FoldFunc(): number
+ return v:lnum
+ enddef
+
+ set foldmethod=expr
+ set foldexpr=s:FoldFunc()
+ END
+ call writefile(lines, 'XfoldExpr', 'D')
+ source XfoldExpr
+
+ call setline(1, ['one', 'two', 'three'])
+ redraw
+ call assert_equal(1, foldlevel(1))
+ call assert_equal(2, foldlevel(2))
+ call assert_equal(3, foldlevel(3))
+
+ bwipe!
+ set foldmethod& foldexpr&
+endfunc
+
func Check_foldlevels(expected)
call assert_equal(a:expected, map(range(1, line('$')), 'foldlevel(v:val)'))
endfunc