Closed bmarcaur closed 8 years ago
Sorry I just noticed your bug reporting style guide:
The problem is that, as you noticed, according to the grammar, the for
keyword marks the start of a for or for-in loop, if it starts at a word boundary.
This means that the easiest way to solve the problem would be to define the "correct" word chars for a posix shell grammar, which includes pretty much everything except whitespace and [;|&]
, unless they're escaped.
That last one is the tricky part, a look-behind would have to look for
Then we'd have to replace every occurrence of \b
in the grammar with that look-behind.
And all that effort (and duplication!) never seemed worth it to me.
I'll be happy to hear your thoughts about this, and I apologize I took so long to get back to you.
Another case that affected me recently:
source `xcode-select -print-path`/usr/share/git-core/git-completion.bash
The select
part of xcode-select
assumes bash's select construct and syntax highlighting is broken from then on.
I committed a change to mkhl/shellscript.tmbundle@cb6e72e1dff7ed234e3cd2bdf1dc065e19787ca9 that should fix this issue. Would you care to try it?
Example:
Currently most of the regex's use word boundaries as their bounding for highlighting, yet using variable names with dash casing will be captured in the regex's. Also in the screen shot above builtin bash strings will highlight even if they are the beginning of a word that is delimited by dashes.
I started by using this look behind:
(?<!-)
to ignore words that follow a dash but I quickly realized that this was gonna be very verbose and really stemmed from the nature of word boundaries in regex. Regex treats '-' as a boundary while bash does not. So to remedy this issue I was thinking that I could replace all the \b with a better definition of a bash centric word boundary. Something like (?<![\w-])(EXPR)(?![\w-])
What are your thoughts on this approach?
Thanks