char_u buf[FOLD_TEXT_LEN];
foldinfo_T foldinfo;
int fold_count;
+ static int entered = FALSE;
#endif
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
#ifdef FEAT_FOLDING
+ if (entered)
+ return; /* reject recursive use */
+ entered = TRUE;
+
lnum = get_tv_lnum(argvars);
/* treat illegal types and illegal string values for {lnum} the same */
if (lnum < 0)
text = vim_strsave(text);
rettv->vval.v_string = text;
}
+
+ entered = FALSE;
#endif
}
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"])
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