]> granicus.if.org Git - vim/commitdiff
patch 7.4.700 v7.4.700
authorBram Moolenaar <Bram@vim.org>
Wed, 15 Apr 2015 10:43:50 +0000 (12:43 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 15 Apr 2015 10:43:50 +0000 (12:43 +0200)
Problem:    Fold can't be opened after ":move". (Ein Brown)
Solution:   Delete the folding information and update it afterwards.
            (Christian Brabandt)

src/ex_cmds.c
src/fold.c
src/testdir/test45.in
src/testdir/test45.ok
src/version.c

index 978d516f7d800c5f20d72d9b1e40e58a1f1295d0..1abda7423b9bbe4b922c97f669843e1be66bbbef 100644 (file)
@@ -741,6 +741,16 @@ do_move(line1, line2, dest)
     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 */
+#ifdef FEAT_FOLDING
+    int                isFolded;
+
+    /* 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. */
+    isFolded = hasAnyFolding(curwin) && !foldmethodIsManual(curwin);
+    if (isFolded)
+       deleteFoldRecurse(&curwin->w_folds);
+#endif
 
     if (dest >= line1 && dest < line2)
     {
@@ -839,6 +849,12 @@ do_move(line1, line2, dest)
     else
        changed_lines(dest + 1, 0, line1 + num_lines, 0L);
 
+#ifdef FEAT_FOLDING
+       /* recreate folds */
+       if (isFolded)
+           foldUpdateAll(curwin);
+#endif
+
     return OK;
 }
 
index 671bbf75a14f4bf4738b0b4066b2aea3fb20e86f..21e455bb191bfc2269e39797ad67321cab01b7b5 100644 (file)
@@ -847,8 +847,8 @@ foldUpdate(wp, top, bot)
     fold_T     *fp;
 
     /* 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
+    (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;
index e5af5073d909998feb70164aa0f080821f65076c..b1e8266ab6fcc0e79653ee83e2d23fe9aae41f7d 100644 (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\e
+:set fdm=indent
+:1m1
+2jzc:m0
+:%w >> test.out
 :qa!
 ENDTEST
 
index f04996e337eeae186140330c184c89f1335f0c7f..0f25e6218a8aec2f25c0c35eb5352b4d87f2d4cb 100644 (file)
@@ -16,3 +16,8 @@ expr 2
 1
 2
 0
+       Test fdm=indent START
+       line3
+       line4
+Test fdm=indent and :move bug END
+line2
index 9d1eb797701e80ff71a54a89e166738afeea4d4a..c03b9a4c575cc8cdda50ce9158e45c48f7d00458 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    700,
 /**/
     699,
 /**/