atom / language-ruby

Ruby package for Atom
Other
101 stars 144 forks source link

🐛 Properly handle variables ending in "do" followed by pipes #215

Closed stevenpetryk closed 7 years ago

stevenpetryk commented 7 years ago

Description of the Change

Variables ending in "do" followed by || or ||= were mistakenly treated as blocks by the grammar:

The grammar was naively treating do | as a block. This PR just adds a few extra checks to ensure that do is not immediately preceded by an identifier character.

Tada!

Alternate Designs

It would be nice if this could be done using a more sane regex, but that is impossible since a lookbehind is necessary. Imagine if it were this:

\b(do|{)\s*|

Wouldn't that be nice!

Benefits

Variables ending in do will not be confused with blocks. This is especially great for Spanish variable names.

Possible Drawbacks

Can't imagine any, this is just a syntax.

Applicable Issues

Fixes #214.

winstliu commented 7 years ago

Ouch...looks like I'll have to take some time to clean these regexes up.