On Mi, 29 Mai 2013, Christian Brabandt wrote:

> On Wed, May 29, 2013 13:33, Bram Moolenaar wrote:
> >
> > Christian Brabandt wrote:
> >
> >> On Fr, 24 Mai 2013, Christian Brabandt wrote:
> >>
> >> > On Fr, 24 Mai 2013, Ein Brown wrote:
> >> >
> >> > > The SO question has more details:
> >> > > http://stackoverflow.com/questions/16592654/in-vim-why-is-move-randomly-corrupting-my-folds
> >> > >
> >> > > at the bottom of the SO question (under 'edit') I explain ways to
> >> run into the bug without the Alt-Up / Alt-Down mapping.
> >> >
> >> > I just saw the problem yesterday. Here is an simpler example of the
> >> bug:
> >> >
> >> > I think this patch fixes it.
> >> [...]
> >>
> >> No, it doesn't fix it completely. I'll look into it some more.
> >
> > Any progress?  What still fails?
> >
> 
> No, I can't figure out why curwin->w_folds gets out of order and
> also sometimes many more folds.
> I haven't really figured out the complete foldUpdate process yet.

Well here is a patch, that deletes the foldinfo and recreates it after 
moving is finished. Admittedly, this doesn't solve the problem, but I 
think it is actually simpler to delete and recreate the fold info, then 
to update the curwin->w_folds several times for a single :move command.

This patch is against 7.3.1006, so does not include the changes 
introduced by 7.3.1042.

regards,
Christian

-- 
-- 
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/groups/opt_out.


diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -740,6 +740,15 @@
     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)
     {
@@ -836,6 +845,12 @@
     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
@@ -849,8 +849,8 @@
     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;

Raspunde prin e-mail lui