vim-patch:7.4.700

Problem:    Fold can't be opened after ":move". (Ein Brown)
Solution:   Delete the folding information and update it afterwards.
            (Christian Brabandt)

d5f6933d5c
This commit is contained in:
watiko 2016-02-05 12:07:46 +09:00
parent 863e1c91a6
commit 69e448d1d8
5 changed files with 37 additions and 8 deletions

View File

@ -690,9 +690,17 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
{
char_u *str;
linenr_T l;
linenr_T extra; /* Num lines added before line1 */
linenr_T num_lines; /* Num lines moved */
linenr_T last_line; /* Last line in file after adding new text */
linenr_T extra; // Num lines added before line1
linenr_T num_lines; // Num lines moved
linenr_T last_line; // Last line in file after adding new text
// Moving lines seems to corrupt the folds, delete folding info now
// and recreate it when finished. Don't do this for manual folding, it
// would delete all folds.
bool isFolded = hasAnyFolding(curwin) && !foldmethodIsManual(curwin);
if (isFolded) {
deleteFoldRecurse(&curwin->w_folds);
}
if (dest >= line1 && dest < line2) {
EMSG(_("E134: Move lines into themselves"));
@ -777,8 +785,14 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
if (dest > last_line + 1)
dest = last_line + 1;
changed_lines(line1, 0, dest, 0L);
} else
} else {
changed_lines(dest + 1, 0, line1 + num_lines, 0L);
}
// recreate folds
if (isFolded) {
foldUpdateAll(curwin);
}
return OK;
}

View File

@ -767,9 +767,9 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
return;
}
/* Mark all folds from top to bot as maybe-small. */
(void)foldFind(&curwin->w_folds, top, &fp);
while (fp < (fold_T *)curwin->w_folds.ga_data + curwin->w_folds.ga_len
// Mark all folds from top to bot as maybe-small.
(void)foldFind(&wp->w_folds, top, &fp);
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
&& fp->fd_top < bot) {
fp->fd_small = MAYBE;
++fp;

View File

@ -63,6 +63,16 @@ endfun
:call append("$", foldlevel("."))
:/^last/+1,$w! test.out
:delfun Flvl
:new
iTest fdm=indent and :move bug END
line2
Test fdm=indent START
line3
line4
:set fdm=indent
:1m1
2jzc:m0
:%w >> test.out
:qa!
ENDTEST

View File

@ -16,3 +16,8 @@ expr 2
1
2
0
Test fdm=indent START
line3
line4
Test fdm=indent and :move bug END
line2

View File

@ -588,7 +588,7 @@ static int included_patches[] = {
// 703 NA
702,
// 701 NA
// 700,
700,
699,
698,
697,