mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
vim-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 vim/vim#7767)
f9547eb6ef
This commit is contained in:
@@ -2999,7 +2999,6 @@ static void foldlevelDiff(fline_T *flp)
|
|||||||
static void foldlevelExpr(fline_T *flp)
|
static void foldlevelExpr(fline_T *flp)
|
||||||
{
|
{
|
||||||
win_T *win;
|
win_T *win;
|
||||||
int n;
|
|
||||||
int c;
|
int c;
|
||||||
linenr_T lnum = flp->lnum + flp->off;
|
linenr_T lnum = flp->lnum + flp->off;
|
||||||
|
|
||||||
@@ -3017,7 +3016,7 @@ static void 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. */
|
||||||
const bool save_keytyped = KeyTyped;
|
const bool save_keytyped = KeyTyped;
|
||||||
n = (int)eval_foldexpr(flp->wp->w_p_fde, &c);
|
const int n = eval_foldexpr(flp->wp->w_p_fde, &c);
|
||||||
KeyTyped = save_keytyped;
|
KeyTyped = save_keytyped;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@@ -3202,8 +3201,10 @@ int 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If some folds are manually opened/closed, need to restore that. */
|
/* If some folds are manually opened/closed, need to restore that. */
|
||||||
|
@@ -291,6 +291,32 @@ endfunc
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
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.
|
||||||
|
Reference in New Issue
Block a user