BracketHighlighter icon indicating copy to clipboard operation
BracketHighlighter copied to clipboard

Some ruby keywords with optional do matched incorrectly

Open xeron opened this issue 2 years ago • 2 comments

Description

Some (or all?) ruby keywords with optional do matched incorrectly (e.g. while, until).

Support Info

  • ST ver.: 4152
  • Platform: osx
  • Arch: x64
  • Plugin ver.: 2.31.1
  • Install via PC: True
  • mdpopups ver.: 4.2.2
  • backrefs ver.: 5.0
  • markdown ver.: 3.2.2
  • pygments ver.: 2.1a0
  • jinja2 ver.: 2.10.1

Steps to Reproduce Issue

Example which doesn't work (with do):

10.times do
  while true do
    puts 1
  end
end

Example which works (without do):

10.times do
  while true
    puts 1
  end
end

Screenshot 2023-09-21 at 4 04 12 PM

xeron avatar Sep 21 '23 23:09 xeron

Keep in mind, I don't code in Ruby, so anything that is implemented was mainly due to feedback from Ruby users. Most likely it is pairing do / end and while / end. But now we have a while / do / end. I'm not sure what to do with that.

facelessuser avatar Sep 22 '23 01:09 facelessuser

Ugh, it seems that do in both while and for (maybe others, I really don't know as I don't use Ruby) is completely optional and does absolutely nothing. What a frustrating syntax. I guess, every time we are validating a do, we have to try and analyze if it is part of a while or for loop? 🤷🏻

The only thing I can suggest for now is to leave off the optional do if this is a problem, or just disable BracketHighligher for Ruby keywords. Every time I fix something in this language, a new case I wasn't aware of surfaces making this much more difficult.

If someone who knows Ruby wants to try a PR to fix this, I'd be more than happy to take a look; otherwise, you'd have to wait for me to find the time to look into this.

facelessuser avatar Sep 22 '23 02:09 facelessuser