klorenz / atom-regex-railroad-diagrams

display regex as railroad diagram, if cursor moves to it
MIT License
250 stars 31 forks source link

Punctuation skipping is too aggressive #48

Closed lordjavac closed 9 years ago

lordjavac commented 9 years ago

The regex scope narrowing by skipping punctuation scopes is too aggressive. It causes errors if the regex begins or ends with a group (or other regex punctuation). It should only skip "punctuation.section.regexp" (begin and end), not "punctuation.definition.group" for example. The problem manifests as an unbalanced group but also occurs more subtly if the group is at both ends of the regex (the grouping disappears from the diagram).

The regex /(foo|bar)/ illustrates the disappearing grouping. And /(foo|bar)$/ illustrates the unbalanced grouping error.

klorenz commented 9 years ago

Hi lordjavac,

this is a ruby-specific issue. and the fix works only for ruby. I have to improve this scope matching.