facelessuser / BracketHighlighter

Bracket and tag highlighter for Sublime Text
https://facelessuser.github.io/BracketHighlighter/
1.74k stars 245 forks source link

do end no longer highlighting in HTML (Rails) file #601

Closed atstockland closed 2 years ago

atstockland commented 2 years ago

Description

At some point in the recent past, with no settings changes on my part, BH stopped highlighting ruby do/end blocks in HTML (Rails) files in Sublime Text. I've experimented with this to get it working again, but have been unsuccessful. I also can not determine if this break is related to an update in BH or ST.

Support Info

Steps to Reproduce Issue

  1. Install BracketHighlighter via Package Control2.
  2. Create a new file with extension xxx.html.erb. Be sure the file type in ST is "HTML (Rails)
  3. Create a ruby do/end block of code. Click on the "do" and notice the "end" is not highlighted as expected.

More info...

If I change the file type in ST to "Ruby (Rails)", some do/end blocks highlight, while others do not. In a rails controller or helper, everything works fine...it's only HTML (Rails) erb files that have stopped working as expected.

facelessuser commented 2 years ago

I'm going to need a reproducible example. Please provide a copy/paste example and let me know what syntax highlighter package you are using. Keep in mind that I do not use all the languages that are supported.

atstockland commented 2 years ago

I'm not sure what syntax highlighter package I'm using. I installed BracketHighligher via PackageControl...thats it. I'm not sure how to provide a reproducible example, either. I can create a simple html.erb file with a ruby block in it...and, it won't highlight. But, I can't imagine that would be helpful in troubleshooting.

facelessuser commented 2 years ago

I don't use Ruby, so I need a Ruby example. I don't want to hunt down a tutorial to learn how to write a Ruby snippet of code.

atstockland commented 2 years ago

Oh. Sorry about that!

show.html.erb file

<%= tag.div do %> <%= tag.p "some random string" %> <% end %>

In Sublime Text this file will render using HTML (Rails). As selected in the bottom right of the ST view window.

It used to be that putting the cursor on the "do" would highlight the "end", or visa-versa. But, now...selecting either doesn't highlight the other. I'm not sure if it is a local setting, or a bug. Thanks so much for inquiring on this issue!!

Adam

facelessuser commented 2 years ago
Screen Shot 2022-04-10 at 4 00 03 PM

It's most likely due to the syntax highlighter for Ruby and HTML changing at some point. I'm using the default HTML (Rails) syntax highlighter that comes with ST, and it looks like this for me.

The highlighting looks a little busted to begin with. Why is the p in tab.p highlighted like a function? I assume this is a bug in the highlighter. Regardless, the rules for BH should be updated to properly work with the recent syntax changes.

atstockland commented 2 years ago
image

In a rails controller the def and end highlight correctly. This is exactly how do/end used to get formatted in view files (html.erb). It's so helpful in longer methods or views, to see where the block is. In your example image above...if you select the "do" the "end" should highlight just like the photo here.

Thanks for the follow up and the update! This plugin is amazing! I wish I could be more help to you troubleshooting it.

facelessuser commented 2 years ago

Bracket rules are often based not just on keywords, but the scoping provided by the syntax highlighter. For instance, we don't target keywords in comments and strings. But when we are relying on specific scopes to identify embedded ruby in HTML, and someone upstream changes how that info is scoped, it can break BH's expectations, and in turn, its ability to properly find the brackets (in this case do/end, etc.).

BH hasn't changed anything major in quite a long time, so this breakage was introduced due to a recent Sublime release which broke our scoping expecations.

atstockland commented 2 years ago

Awesome!!! Thank you so much.