On Di, 14 Apr 2015, Christian Brabandt wrote:
> I'll post an updated patch including a test later.

Updated patch (including test) attached.

Best,
Christian
-- 
Wer nicht auf seine Weise denkt, denkt überhaupt nicht.
                -- Oscar Wilde

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -741,6 +741,15 @@ 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 */
+    isFolded = hasAnyFolding(curwin);
+    if (isFolded)
+	deleteFoldRecurse(&curwin->w_folds);
+#endif
 
     if (dest >= line1 && dest < line2)
     {
@@ -839,6 +848,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;
 }
 
diff --git a/src/fold.c b/src/fold.c
--- a/src/fold.c
+++ b/src/fold.c
@@ -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;
diff --git a/src/testdir/test45.in b/src/testdir/test45.in
--- a/src/testdir/test45.in
+++ b/src/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/testdir/test45.ok b/src/testdir/test45.ok
--- a/src/testdir/test45.ok
+++ b/src/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

Raspunde prin e-mail lui