klorenz / atom-regex-railroad-diagrams

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

Not working in files indented with tabs #58

Closed kgram closed 9 years ago

kgram commented 9 years ago

It seems the parser makes some wierd assumptions about tab size when using tabs. It correctly identifies regexes, but misplaces their position in the line as if spaces was used.

Example from a line indented with 3 tabs with tab-width set to 4:

.replace(/(\+\d+)? ?(\d{2}) ?(\d{2}) ?(\d{2}) ?(\d{2})/g, '$1 $2 $3 $4 $5')

results in the error

?(\d{2}) ?(\d{2}) ?(\d{2}) ?(\d{2})/g, '$1 $2
Expected "^" but "?" found.

You'll note the regex given is offset by 9 characters, the difference between indenting with tabs and spaces. The diagram is also only visible when the cursor is inside the string given, rather than inside the actual regex. Running tabs to spaces fixes the problem (but is of course not an option, as the project uses tabs).

klorenz commented 9 years ago

Hi, yes indeed. I am using atom API function editor.bufferRangeForScopeAtCursor(scope) for getting the range. This returns wrong values :(

klorenz commented 9 years ago

fixed (workaround) in 0.10.0