0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 8.2.2447: 'foldlevel' not applied to folds restored from session

Problem:    'foldlevel' not applied to folds restored from session.
Solution:   Set 'foldlevel' after creaiting the folds. (closes #7767)
This commit is contained in:
Bram Moolenaar
2021-02-01 19:24:55 +01:00
parent 5daa911626
commit f9547eb6ef
3 changed files with 31 additions and 2 deletions

View File

@@ -3309,7 +3309,7 @@ foldlevelExpr(fline_T *flp)
// KeyTyped may be reset to 0 when calling a function which invokes // KeyTyped may be reset to 0 when calling a function which invokes
// do_cmdline(). To make 'foldopen' work correctly restore KeyTyped. // do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
save_keytyped = KeyTyped; save_keytyped = KeyTyped;
n = (int)eval_foldexpr(flp->wp->w_p_fde, &c); n = eval_foldexpr(flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped; KeyTyped = save_keytyped;
switch (c) switch (c)
@@ -3526,7 +3526,8 @@ put_folds(FILE *fd, win_T *wp)
if (foldmethodIsManual(wp)) if (foldmethodIsManual(wp))
{ {
if (put_line(fd, "silent! normal! zE") == FAIL if (put_line(fd, "silent! normal! zE") == FAIL
|| put_folds_recurse(fd, &wp->w_folds, (linenr_T)0) == FAIL) || put_folds_recurse(fd, &wp->w_folds, (linenr_T)0) == FAIL
|| put_line(fd, "let &fdl = &fdl") == FAIL)
return FAIL; return FAIL;
} }

View File

@@ -504,6 +504,32 @@ func Test_mkview_terminal_windows()
call delete('Xtestview') call delete('Xtestview')
endfunc endfunc
func Test_mkview_open_folds()
enew!
call append(0, ['a', 'b', 'c'])
1,3fold
" zR affects 'foldlevel', make sure the option is applied after the folds
" have been recreated.
normal zR
write! Xtestfile
call assert_equal(-1, foldclosed(1))
call assert_equal(-1, foldclosed(2))
call assert_equal(-1, foldclosed(3))
mkview! Xtestview
source Xtestview
call assert_equal(-1, foldclosed(1))
call assert_equal(-1, foldclosed(2))
call assert_equal(-1, foldclosed(3))
call delete('Xtestview')
call delete('Xtestfile')
%bwipe
endfunc
" Test :mkview with a file argument. " Test :mkview with a file argument.
func Test_mkview_file() func Test_mkview_file()
" Create a view with line number and a fold. " Create a view with line number and a fold.

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2447,
/**/ /**/
2446, 2446,
/**/ /**/