aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-02-07 01:33:01 -0500
committerJustin M. Keyes <justinkz@gmail.com>2016-02-07 01:33:01 -0500
commit827e267800417b8fdd1340d54f5dc5fa9d81bb92 (patch)
treed9b03388ce0f9596d20e23b824d4a0385fd4a443 /src/nvim/ex_cmds.c
parentcc520602458c693645a9d2ad75fcf7796bc38e0c (diff)
parent3cf8ad6f48da3239619e95a52017b1a191789c2a (diff)
downloadrneovim-827e267800417b8fdd1340d54f5dc5fa9d81bb92.tar.gz
rneovim-827e267800417b8fdd1340d54f5dc5fa9d81bb92.tar.bz2
rneovim-827e267800417b8fdd1340d54f5dc5fa9d81bb92.zip
Merge pull request #4175 from watiko/vim-7.4.700
vim-patch:7.4.700
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c22
1 files changed, 18 insertions, 4 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;
}