bug with folding

38 views
Skip to first unread message

Christian Brabandt

unread,
Aug 29, 2016, 4:39:18 AM8/29/16
to vim...@vim.org

Bram,
I am currently writing some tests for normal.c, to increase the coverage.

Unfortunately, I noteiced some bugs with folding: Here is one issue:

~$ vim -u NONE -N
call setline(1, range(1,10)
:3
norm! 2zF
:2
norm! 5zF
:set nofoldenable
:3
norm! zc -> folds line 2 - 8, I would have expected to only close the inner fold 3-4, but perhaps that is expected, but see below:
set nofoldenable
norm! Vzc -> correctly folds 3-4
:set nofoldenable
norm! zc -> folds lines 3-4?

Also I got another session, where zF create one additional closing fold marker
several lines below where it definitly shouldn't. Unfortunately, I can't reproduce this problem anymore.

Best,
Christian

Bram Moolenaar

unread,
Aug 29, 2016, 3:56:07 PM8/29/16
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> I am currently writing some tests for normal.c, to increase the coverage.
>
> Unfortunately, I noteiced some bugs with folding: Here is one issue:
>
> ~$ vim -u NONE -N
> call setline(1, range(1,10)
> :3
> norm! 2zF
> :2
> norm! 5zF
> :set nofoldenable
> :3
> norm! zc -> folds line 2 - 8, I would have expected to only close the inner fold 3-4, but perhaps that is expected, but see below:
> set nofoldenable
> norm! Vzc -> correctly folds 3-4
> :set nofoldenable
> norm! zc -> folds lines 3-4?

Isn't this because 'foldlevel' keeps the same value when 'foldenable' is
reset?

> Also I got another session, where zF create one additional closing
> fold marker several lines below where it definitly shouldn't.
> Unfortunately, I can't reproduce this problem anymore.

The rules for opening a closing folds are a bit complicated...
It's possible there is a bug, but it's also possible that something is
missing in the documentation. I notice "zc" doesn't say anything about
'foldlevel'.

--
hundred-and-one symptoms of being an internet addict:
97. Your mother tells you to remember something, and you look for
a File/Save command.

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

Christian Brabandt

unread,
Aug 29, 2016, 4:13:45 PM8/29/16
to vim...@vim.org
Hi Bram!

On Mo, 29 Aug 2016, Bram Moolenaar wrote:

>
> Christian Brabandt wrote:
>
> > I am currently writing some tests for normal.c, to increase the coverage.
> >
> > Unfortunately, I noteiced some bugs with folding: Here is one issue:
> >
> > ~$ vim -u NONE -N
> > call setline(1, range(1,10)
> > :3
> > norm! 2zF
> > :2
> > norm! 5zF
> > :set nofoldenable
> > :3
> > norm! zc -> folds line 2 - 8, I would have expected to only close the inner fold 3-4, but perhaps that is expected, but see below:
> > set nofoldenable
> > norm! Vzc -> correctly folds 3-4
> > :set nofoldenable
> > norm! zc -> folds lines 3-4?
>
> Isn't this because 'foldlevel' keeps the same value when 'foldenable' is
> reset?

But I never messed with the foldlevel setting.

Also, it seems, it is not so easily reproducible, as I initially
thought. Sometimes it happens for me, and sometimes it always folds
lines 2-8 but I never saw that it changes the foldlevel setting

> > Also I got another session, where zF create one additional closing
> > fold marker several lines below where it definitly shouldn't.
> > Unfortunately, I can't reproduce this problem anymore.
>
> The rules for opening a closing folds are a bit complicated...
> It's possible there is a bug, but it's also possible that something is
> missing in the documentation. I notice "zc" doesn't say anything about
> 'foldlevel'.

Adding to the documentation does help, as I only test according to the
documentation and do not read the source. Hm, will have to further
investigate.

Best,
Christian

Christian Brabandt

unread,
Aug 30, 2016, 3:05:36 AM8/30/16
to vim...@googlegroups.com
Am 2016-08-29 22:13, schrieb Christian Brabandt:
> Hi Bram!
>
> On Mo, 29 Aug 2016, Bram Moolenaar wrote:
>
>>
>> Christian Brabandt wrote:
>>
>> > I am currently writing some tests for normal.c, to increase the coverage.
>> >
>> > Unfortunately, I noteiced some bugs with folding: Here is one issue:
>> >
>> > ~$ vim -u NONE -N
>> > call setline(1, range(1,10)
>> > :3
>> > norm! 2zF
>> > :2
>> > norm! 5zF
>> > :set nofoldenable
>> > :3
>> > norm! zc -> folds line 2 - 8, I would have expected to only close the inner fold 3-4, but perhaps that is expected, but see below:
>> > set nofoldenable
>> > norm! Vzc -> correctly folds 3-4
>> > :set nofoldenable
>> > norm! zc -> folds lines 3-4?

Actually, I can't seem to verify this bug on a recent Vim. It seems to
always fold the longer range.
Can someone confirm this behaviour?

Best,
Christian
Reply all
Reply to author
Forward
0 new messages