diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_cmds.c | 22 | ||||
-rw-r--r-- | src/nvim/fold.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test45.in | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test45.ok | 5 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
5 files changed, 37 insertions, 8 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index a517037431..4d62dd0ff9 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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; } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 2e32e78062..6c135ef47b 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -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; diff --git a/src/nvim/testdir/test45.in b/src/nvim/testdir/test45.in index e5af5073d9..b1e8266ab6 100644 --- a/src/nvim/testdir/test45.in +++ b/src/nvim/testdir/test45.in @@ -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 diff --git a/src/nvim/testdir/test45.ok b/src/nvim/testdir/test45.ok index f04996e337..0f25e6218a 100644 --- a/src/nvim/testdir/test45.ok +++ b/src/nvim/testdir/test45.ok @@ -16,3 +16,8 @@ expr 2 1 2 0 + Test fdm=indent START + line3 + line4 +Test fdm=indent and :move bug END +line2 diff --git a/src/nvim/version.c b/src/nvim/version.c index f865e13f55..f818acb801 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -588,7 +588,7 @@ static int included_patches[] = { // 703 NA 702, // 701 NA - // 700, + 700, 699, 698, 697, |