On Tue, Nov 29, 2016 at 7:02 PM, Ben Fritz <[email protected]> wrote:
> On Wednesday, November 23, 2016 at 4:39:24 AM UTC-6, Efraim Yawitz wrote:
> > I had the following problem and I think it is a bug in some fold-related
> code:
> >
> > I was trying to use the NarrowRegion plugin to do diffs between two
> functions in the same file by creating narrowed buffers for each function
> and calling :diffthis on them. When I tried to do this using folds, i.e.
> :.,+2NarrowRegion to create a buffer for a folded-up function which looked
> like this:
> >
> > int FuncName() {
> > .....folded........
> > }
> >
> > I got everything but the final brace in the narrowed buffer. Eventually
> I discovered that this has nothing to do with NarrowRegion, but just a yank
> such as:
> >
> > :.,+2y
> >
> > over a fold gives only the folded lines but not the line after the fold.
> >
> > A normal command of y2j works just fine and gets the line after the
> fold.
>
> I can confirm this looks like a bug, seeing the same behavior in 64-bit
> Vim 8.0.95 on Windows 7.
>
> It gets worse actually. I tried several yanks from code that looks like
> this in Vim:
>
> else
> { ---3 lines folded--- }
> #endif
>
> if ( ---2 lines folded--- )
>
> With the cursor on the top "else" line:
>
> :.,+2y yanks only the "else" and the folded lines beneath, when I expect
> to also get the #endif
>
> :.,+3y yanks the exact same thing (omitting the #endif *and* the empty
> line)
>
> :.,+4y finally includes the #endif (with nothing after it) but I expected
> it to yank everything from "else" to the content of the second folded
> section.
>
> The :d command acts in the same way.
>
> It appears something is wrong with handling of folded lines in the ranges
> specified for ex commands.
>
> Forwarding to vim_dev as this appears to be a bug.
>
Thanks. As I wrote before, the handling of folds in do_one_cmd just has
one call to hasFolding() for the end of the fold while in cursor_down() in
edit.c, there is the following code which seems to take care of all folds:
#ifdef FEAT_FOLDING
if (hasAnyFolding(curwin))
{
linenr_T last;
/* count each sequence of folded lines as one logical line */
while (n--)
{
if (hasFolding(lnum, NULL, &last))
lnum = last + 1;
else
++lnum;
if (lnum >= curbuf->b_ml.ml_line_count)
break;
}
if (lnum > curbuf->b_ml.ml_line_count)
lnum = curbuf->b_ml.ml_line_count;
}
else
#endif
>
> --
> --
> You received this message from the "vim_use" 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_use" 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.
>
--
--
You received this message from the "vim_use" 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_use" 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.