Re: Fold-related bug and pointer to fix

45 views
Skip to first unread message

Ben Fritz

unread,
Nov 29, 2016, 12:02:29 PM11/29/16
to vim_use, vim_dev
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.

Ben Fritz

unread,
Dec 14, 2016, 12:26:15 AM12/14/16
to vim_use, vim_dev
On Tuesday, December 13, 2016 at 6:37:54 AM UTC-6, Efraim Yawitz wrote:
> Has any fix been made for this?  I'm not subscribed to vim_dev, and there are a lot of messages to look through in the archives.
>
> Thanks,
>
> Ephraim
>
>

I don't see it in the todo list nor do I see it in the recent patches.

Christian Brabandt

unread,
Dec 16, 2016, 5:58:42 AM12/16/16
to vim...@googlegroups.com, vim-dev, Efraim Yawitz
Bram,
attached is a patch, that changes slightly how addresses are being
calculated when on a folded line and using an relative offset.

Best,
Christian
--
Mißtrauen ist eine schlechte Rüstung, die mehr hindern als schirmen
kann.
-- George Gordon
0001-Correct-ex-range-for-folded-lines.patch

Bram Moolenaar

unread,
Dec 16, 2016, 9:07:30 AM12/16/16
to vim...@googlegroups.com, Christian Brabandt, vim-dev, Efraim Yawitz

Christian Brabandt wrote:

> Bram,
> attached is a patch, that changes slightly how addresses are being
> calculated when on a folded line and using an relative offset.

Thanks! I'm afraid the list of patches to include is getting longer,
and I don't have much time, thus it might take a while.

--
The difference between theory and practice, is that in theory, there
is no difference between theory and practice.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages