Patch 8.2.2447

5 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 1, 2021, 1:25:56 PM2/1/21
to vim...@googlegroups.com

Patch 8.2.2447
Problem: 'foldlevel' not applied to folds restored from session.
Solution: Set 'foldlevel' after creaiting the folds. (closes #7767)
Files: src/fold.c, src/testdir/test_mksession.vim


*** ../vim-8.2.2446/src/fold.c 2020-12-21 14:01:38.328550550 +0100
--- src/fold.c 2021-02-01 19:22:05.395427114 +0100
***************
*** 3309,3315 ****
// KeyTyped may be reset to 0 when calling a function which invokes
// do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
save_keytyped = KeyTyped;
! n = (int)eval_foldexpr(flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped;

switch (c)
--- 3309,3315 ----
// KeyTyped may be reset to 0 when calling a function which invokes
// do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
save_keytyped = KeyTyped;
! n = eval_foldexpr(flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped;

switch (c)
***************
*** 3526,3532 ****
if (foldmethodIsManual(wp))
{
if (put_line(fd, "silent! normal! zE") == FAIL
! || put_folds_recurse(fd, &wp->w_folds, (linenr_T)0) == FAIL)
return FAIL;
}

--- 3526,3533 ----
if (foldmethodIsManual(wp))
{
if (put_line(fd, "silent! normal! zE") == FAIL
! || put_folds_recurse(fd, &wp->w_folds, (linenr_T)0) == FAIL
! || put_line(fd, "let &fdl = &fdl") == FAIL)
return FAIL;
}

*** ../vim-8.2.2446/src/testdir/test_mksession.vim 2020-12-08 20:39:11.361180690 +0100
--- src/testdir/test_mksession.vim 2021-02-01 19:22:05.395427114 +0100
***************
*** 504,509 ****
--- 504,535 ----
call delete('Xtestview')
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.
func Test_mkview_file()
" Create a view with line number and a fold.
*** ../vim-8.2.2446/src/version.c 2021-02-01 18:39:43.327401074 +0100
--- src/version.c 2021-02-01 19:23:35.431147465 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2447,
/**/

--
Facepalm statement #8: "Drive faster, the petrol is running out"

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages