Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around problem with braces messing up syntax highlighting #11

Merged
merged 1 commit into from
Aug 18, 2019

Conversation

mbudde
Copy link
Contributor

@mbudde mbudde commented Jun 8, 2016

As reported in #10, unclosed brackets in templates can mess up the syntax highlighting of the following code. It seems like the Perl highlight region does not end when the template tag ends. I have not identified the source of the issue but excluding the bracket from the Perl highlight region seems to fix the problem.

This patch does not fix cases where there's any non-whitespace characters after the bracket, e.g.

% if (1) { # a comment

This works as a temporary band aid until the real issue is fixed.

As reported in yko#10, unclosed braces in templates can mess up the
syntax highlighting of the following code. It seems the problem is with
the `perlBraces` highlight region in `syntax/perl.vim` which uses the
`extend` argument. This means Perl highlight region extends beyond the
end of the template tag, messing the up the highlighting.

Excluding the `perlBraces` seems to fix this problem. I'm not sure if
there still are some cases where Perl code can cause the highlight
region to be extended.
@mbudde
Copy link
Contributor Author

mbudde commented Jun 8, 2016

I found a much better fix: just exclude the perlBraces highlight group. It seems like the problem is with the extend argument in the perlBraces highlight group. This causes the highlight region to extend beyond the end of the template tag.

Is there a way to tell Vim that we want to force keepend, i.e. it should not be possible to extend the region with extend?

@horgh
Copy link

horgh commented May 10, 2018

Works well, thanks for this!

@yko
Copy link
Owner

yko commented Aug 18, 2019

Thanks a ton, @mbudde! I've added a failing test in c1ad576 to lock this behavior.
Merging this PR now.
Only took me two years, huh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants