Christian Brabandt wrote:

> > Patch 7.4.700
> > Problem:    Fold can't be opened after ":move". (Ein Brown)
> > Solution:   Delete the folding information and update it afterwards.
> >             (Christian Brabandt)
> > Files:      src/ex_cmds.c, src/fold.c, src/testdir/test45.in,
> >             src/testdir/test45.ok
> 
> Recently I have been looking into this issue again. Reason is, I don't 
> like the folds being changed after doing :move.

Thanks for looking into this.  I believe that patch was more like a
workaround than a real solution.

> Turns out, do_move() does finally call mark_adjust with a negative 
> amount (ex_cmds.c:859)
> 
> mark_adjust() calls foldMarkAdjust() which will then call 
> foldMarkAdjustRecurse() which does finally:
> 
> 1561    if (last <= line2)
> 1562    {
> 1563        /* 2. fold contains line1, line2 is below fold */
> 1564        if (amount == MAXLNUM)
> 1565            fp->fd_len = line1 - fp->fd_top;
> 1566        else
> 1567            fp->fd_len += amount;
> 1568    }
> 
> Note, that it unconditionally adds amount to fd_len, which in this 
> particular case means, fp->fd_len becomes negative and I believe this is 
> wrong. So how about just checking, that the sum cannot be negative?

A negative amount means that lines above were deleted, so all the line
numbers become smaller.  As such that is fine, but for a fold the
computations appear to be off.  I would think that if fd_len becomes
zero or negative, that means the fold no longer exists.  So the
condition for the fourth situation seems wrong.

> That is what the attached patch does it and also does not fail test45
> 
> On a related note, what test45 does is calling :1m1 which basically is a 
> no op. We might want to return early in that case from do_move. Also 
> calling mark_adjust with line1==line2 and a negative amount looks 
> certainly wrong to me.

I suspect we don't have enough test coverage. Coveralls shows that the
delete is never reached.  And nested folds are not covered.

I also think that folds still need to be updated, around the area moved
from and around where they are moved to.  Just updating positions may
work for manual folding, but not for other kinds of folding.


-- 
Every exit is an entrance into something else.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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.

Raspunde prin e-mail lui