Regexp within interpolated regexp is not highlighted correctly. #63

Closed
amarshall opened this Issue Feb 3, 2012 · 10 comments

Projects

None yet

3 participants

@amarshall
Contributor

When there is a regular expression that contains interpolation which contains a regular expression, the /s are incorrectly matched and thus the syntax highlighting is thrown off. For example:

/#{foo.sub(/bar/, 'baz')}/

is highlighted as:

/#{foo.sub(/bar/, 'baz')}/

@tpope
Member
tpope commented Feb 3, 2012

Works for me.

@amarshall
Contributor

Really? I'm seeing this in both vanilla Vim 7.3.390 and when loading the current git head of vim-ruby as the only addition to vanilla Vim. Obviously it also appears in my own configuration.

@AndrewRadev
Member

I'm seeing the same problem on my setup. My knowledge of syntax highlighting is pretty limited, though. I poked around a bit and found out that removing keepend from the rubyRegexp syntax group fixes the issue. From what I understood of Vim's help on this, keepend is meant to allow ending a nested pattern with a match for the outer one, which pretty much describes the issue.

The commit that adds the keepend there was made in 2008 by @tpope: 88a38fc. Not sure if there's anything more recent dealing with this, it has a fairly long history.

@tpope, do you remember the reason for the keepend there? This problem a bit of an edge case, so breaking something else to fix it wouldn't be a very good idea...

@tpope
Member
tpope commented Feb 5, 2012

I can reproduce it now. I guess that's what happens when you make me type out a screenshot.

I don't remember the specifics of why I added keepend. But it's a safe guess that it was to fix one of those "the entire rest of the file highlights as a regex" bugs. Which is much worse than this bug.

@amarshall, please try reverting that change and seeing if things work better for you. Though I'm really hesitant to do that globablly without putting a lot of miles on it first.

@amarshall
Contributor

Sorry about that. I've updated the description to include the plain text as well for future reference.

I've removed the keepend from ruby.vim:127 (there were some other changes in that commit that I've left in) and that fixes this issue, though I'm unsure of what other repercussions it may have. I'll let you know if I encounter any.

@AndrewRadev
Member

It's been quite a while since we last talked about the issue. @amarshall, have you noticed any regressions with the keepend removal?

@amarshall
Contributor

I've been using vim-ruby with the patch since I wrote it (so about 9 months) and haven't noticed any problems—though I could have just not run into whatever odd edge case that its removal exposes.

@AndrewRadev
Member

@tpope, what do you think? This really is quite an edge case, so if you don't feel comfortable removing the keepend in master, I don't intend to argue. I'm just poking you to get some closure on this issue.

@tpope
Member
tpope commented Nov 13, 2012

Nuke it. We can always add it back.

On Nov 13, 2012, at 15:26, Andrew Radev notifications@github.com wrote:

@tpope https://github.com/tpope, what do you think? This really is quite
an edge case, so if you don't feel comfortable removing the keepend in
master, I don't intend to argue. I'm just poking you to get some closure on
this issue.


Reply to this email directly or view it on
GitHubhttps://github.com/vim-ruby/vim-ruby/issues/63#issuecomment-10342056.

@AndrewRadev
Member

Nuked and closed.

@jtmkrueger jtmkrueger pushed a commit to jtmkrueger/vim-ruby that referenced this issue Nov 5, 2013
@AndrewRadev AndrewRadev Remove "keepend" from regex syntax highlighting
This fixes an issue with highlighting a regex with interpolation in it
with a regex within.

    /#{foo.sub(/bar/, 'baz')}/

See vim-ruby#63 for details
d2982c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment