patch 8.0.1115: crash when using foldtextresult() recursively
Problem: Crash when using foldtextresult() recursively.
Solution: Avoid recursive calls. (Yasuhiro Matsumoto, closes #2098)
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index 213c0fa..b6ba99c 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -278,6 +278,7 @@
call assert_equal(0, foldlevel(6))
call assert_equal(9, foldclosedend(7))
call assert_equal([-1, 2, 2, 2, 2, -1, 7, 7, 7, -1], map(range(1, line('$')), 'foldclosed(v:val)'))
+
%d
" Ensure moving around the edges still works.
call setline(1, PrepIndent("a") + repeat(["a"], 3) + ["\ta"])
@@ -446,3 +447,16 @@
set foldmethod&
bw!
endfunc
+
+func Test_foldtext_recursive()
+ new
+ call setline(1, ['{{{', 'some text', '}}}'])
+ setlocal foldenable foldmethod=marker foldtext=foldtextresult(v\:foldstart)
+ " This was crashing because of endless recursion.
+ 2foldclose
+ redraw
+ call assert_equal(1, foldlevel(2))
+ call assert_equal(1, foldclosed(2))
+ call assert_equal(3, foldclosedend(2))
+ bwipe!
+endfunc