Hi! When writing my extension, I noticed that a
<strings> scope with the
suffix attribute does not match when syntax highlighting. For example:
Will fail to match
It’s also possible that symbols in particular are failing to match. Looking in the Ruby novaextension, on line 849 in
Ruby.xml there are a bunch of core method strings. One is
But in a ruby file this fails to highlight.
EDIT: apologies, I wasn’t paying attention, as I now see you noted you are trying to match a symbol in the suffix attribute. My answer below applies to why in-string symbol prefixes and suffixes are not matched, like in the builtin Ruby grammar. In your case, I am pretty sure the issue is that only the content of the
<string> tag is highlighted by default. You can highlight parts of the prefix or suffix, but you need to capture the relevant parts in the regex and to define capture groups for these (the docs only mention these for Match Scopes, but they work for String Expressions too).
Outdated answer, left here for documentation purposes:
Matching symbol prefixes or suffixes with
<string> will fail because, by default, the match is on word boundaries (it is a shorthand for writhing
\b(your-string)\b), and there is no word boundary between a symbol and some other non-word character (word boundaries are defined as zero width matches at the spot where a word character, i.e. an alphanumeric character or the underscore, meets a non-word character).
word-boundary="false" attribute to suppress this behaviour. Note that this removes the word boundary marker on both sides of your strings, so you may want to add a
@kopischke No apology necessary Rereading my message I could have been a little more to-the-point.
And thank you, your original answer actually was the solution I needed. Here’s what I ended up with:
<strings prefix="\b" word-boundary="false">
This allowed me to ignore the suffix altogether. One wrinkle is that if I have a single letter string like
<string>p</string> every other string that starts with that letter fails to match. I got around it by using a match block for just that one letter. But this is all a separate issue and I’m just leaving it here for anyone else who’s trying to do something similar.
As far as I’m concerned this is solved.