Re: Implementing nested braces for syntax folding

55 views
Skip to first unread message

Ben Fritz

unread,
May 23, 2013, 9:29:46 PM5/23/13
to vim...@googlegroups.com
On Thursday, May 23, 2013 2:08:16 PM UTC-5, Rob Hoelz wrote:
> Hi all,
>
>
>
> I'm working on bringing the Perl runtime files up to speed for the upcoming 7.4 release, but I've encountered an interesting bug and seek the community's help. Attached is an example Perl file. When using the HEAD of vim-perl (https://github.com/vim-perl/vim-perl), the three subroutines fold properly with the default settings. However, with perl_fold_anonymous_subs set to 1, the folding for the third subroutine (which has attributes, which seems to trigger this odd behavior), the fold is not properly ended

I've wanted for a while to get Perl folding to work based on open-close brace only, instead of relying on indent.

Since you are already messing with the syntax folding, what are the chances of getting that working as part of your updates? I got it working once before it went to github, but I wasn't able to get it working again the last time I tried.

Rob Hoelz

unread,
May 24, 2013, 3:04:48 AM5/24/13
to vim...@googlegroups.com
It's working for the most part; the only problem as of now is that
attributes mess things up (as seen in my example). Also, the current
rules expect the opening brace to be on the same line, but I don't think
that would be *too* hard to fix. (famous last words, right?)

-Rob

Rob Hoelz

unread,
May 24, 2013, 6:50:52 PM5/24/13
to vim...@googlegroups.com
On Thursday, May 23, 2013 9:08:16 PM UTC+2, Rob Hoelz wrote:
> Hi all,
>
>
>
> I'm working on bringing the Perl runtime files up to speed for the upcoming 7.4 release, but I've encountered an interesting bug and seek the community's help. Attached is an example Perl file. When using the HEAD of vim-perl (https://github.com/vim-perl/vim-perl), the three subroutines fold properly with the default settings. However, with perl_fold_anonymous_subs set to 1, the folding for the third subroutine (which has attributes, which seems to trigger this odd behavior), the fold is not properly ended and continues until the end of the file. The opening brace of the subroutine seems to be counted as an inner brace (see the perlBraces rule), even though it's present in the perlSubFold rule (according to synstack), and that's messing up the folding. I understand not everyone has time to look through a complicated several hundred line syntax file, so I've included a minimal syntax file that demonstrates this behavior as well (although min.vim messes up *all* the folds; the problem is the same, though). Could any syntax gurus or Vim developers help me figure out what I'm doing wrong?
>
>
>
> By the way, I'm using Vim 7.3, patch level 1004. If you're testing with a Vim where the patch level is < 970, you'll need to comment out the line setting the regexpengine.
>
>
>
> Thanks,
>
> Rob

I've fixed this; after diving into syntax.c for a little bit, I discovered that an empty match group following attributes would fix it. I would like to understand how syntax.c works better, though...
Reply all
Reply to author
Forward
0 new messages