mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
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:
@@ -690,9 +690,17 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
|||||||
{
|
{
|
||||||
char_u *str;
|
char_u *str;
|
||||||
linenr_T l;
|
linenr_T l;
|
||||||
linenr_T extra; /* Num lines added before line1 */
|
linenr_T extra; // Num lines added before line1
|
||||||
linenr_T num_lines; /* Num lines moved */
|
linenr_T num_lines; // Num lines moved
|
||||||
linenr_T last_line; /* Last line in file after adding new text */
|
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) {
|
if (dest >= line1 && dest < line2) {
|
||||||
EMSG(_("E134: Move lines into themselves"));
|
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)
|
if (dest > last_line + 1)
|
||||||
dest = last_line + 1;
|
dest = last_line + 1;
|
||||||
changed_lines(line1, 0, dest, 0L);
|
changed_lines(line1, 0, dest, 0L);
|
||||||
} else
|
} else {
|
||||||
changed_lines(dest + 1, 0, line1 + num_lines, 0L);
|
changed_lines(dest + 1, 0, line1 + num_lines, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// recreate folds
|
||||||
|
if (isFolded) {
|
||||||
|
foldUpdateAll(curwin);
|
||||||
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@@ -767,9 +767,9 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark all folds from top to bot as maybe-small. */
|
// Mark all folds from top to bot as maybe-small.
|
||||||
(void)foldFind(&curwin->w_folds, top, &fp);
|
(void)foldFind(&wp->w_folds, top, &fp);
|
||||||
while (fp < (fold_T *)curwin->w_folds.ga_data + curwin->w_folds.ga_len
|
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
|
||||||
&& fp->fd_top < bot) {
|
&& fp->fd_top < bot) {
|
||||||
fp->fd_small = MAYBE;
|
fp->fd_small = MAYBE;
|
||||||
++fp;
|
++fp;
|
||||||
|
@@ -63,6 +63,16 @@ endfun
|
|||||||
:call append("$", foldlevel("."))
|
:call append("$", foldlevel("."))
|
||||||
:/^last/+1,$w! test.out
|
:/^last/+1,$w! test.out
|
||||||
:delfun Flvl
|
: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!
|
:qa!
|
||||||
ENDTEST
|
ENDTEST
|
||||||
|
|
||||||
|
@@ -16,3 +16,8 @@ expr 2
|
|||||||
1
|
1
|
||||||
2
|
2
|
||||||
0
|
0
|
||||||
|
Test fdm=indent START
|
||||||
|
line3
|
||||||
|
line4
|
||||||
|
Test fdm=indent and :move bug END
|
||||||
|
line2
|
||||||
|
@@ -588,7 +588,7 @@ static int included_patches[] = {
|
|||||||
// 703 NA
|
// 703 NA
|
||||||
702,
|
702,
|
||||||
// 701 NA
|
// 701 NA
|
||||||
// 700,
|
700,
|
||||||
699,
|
699,
|
||||||
698,
|
698,
|
||||||
697,
|
697,
|
||||||
|
Reference in New Issue
Block a user