1
0
forked from aniani/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'
This commit is contained in:
Bram Moolenaar
2022-10-01 15:32:46 +01:00
parent 145d1fd910
commit 87b4e5c5db
8 changed files with 144 additions and 11 deletions

View File

@@ -249,6 +249,31 @@ func Test_foldexpr_no_interrupt_addsub()
set foldmethod& foldexpr&
endfunc
" Fold function defined in another script
func Test_foldexpr_compiled()
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