When a string (e.g. "foo", 'foo') is on the same line with other words, syntax highlighting breaks on some of those words.


As seen in the images, when I remove the string from the line, all the other highlighting works as expected.
I made some tests. When I use constant.string: "\".*\"|\'.*\'" in the syntax file this doesn't happen, but multiline strings don't get highlighted. The issue happens if I use:
# ~/.config/micro/syntax/sh.yaml.
- constant.string:
start: "\'"
end: "\'"
rules: [ ]
- constant.string:
start: "\""
end: "\""
rules: [ ]
Commit hash: 3a8898d -> 1.4.2-dev.77; compiled on July 27, 2019.
OS: Manjaro.
Terminal: xterm-256-color.
After reading the documentation a bit, I noticed that this issue happens with any region, not just strings.
So, whenever a region is found in the same line after a pattern or patterns, some of the patterns are ignored (but I can't tell which ones, it seems to be random; some work, some don't).
Until now what I have done is avoiding using regions (which leaves me with just single-line strings highlighting).
As seen in the screenshots, I was coding shell scripts, which have a kind of "exotic" syntax when it comes to strings (everything is a string!). You can recursively embed strings into strings, perform variable expansions (which may have embedded strings), command substitution (which may also have embedded strings), etc. It's impossible to correctly parse the shell with just regular expressions (i.e. without using regions), because they may overlap (_you need a recursive parser to correctly parse a shell script_).
I've also been running into this bug recently.
I've been able to reduce down to a minimal syntax definition to reproduce the bug:
filetype: foobar
detect:
filename: "\\.foo$"
rules:
- symbol: "[$]"
- comment:
start: "#"
end: "$"
rules: []
which renders the following:

Notice how the last $ has no highlighting.
If the regex tries to match a $, then it stops working on lines affected by regions.
Version: 2.0.6
Commit hash: 60846f5
Compiled on June 24, 2020
I have a similar issue - any pattern that is encountered after the region rule, gets unhighlighted.
Most helpful comment
After reading the documentation a bit, I noticed that this issue happens with any region, not just strings.
So, whenever a region is found in the same line after a pattern or patterns, some of the patterns are ignored (but I can't tell which ones, it seems to be random; some work, some don't).
Until now what I have done is avoiding using regions (which leaves me with just single-line strings highlighting).
As seen in the screenshots, I was coding shell scripts, which have a kind of "exotic" syntax when it comes to strings (everything is a string!). You can recursively embed strings into strings, perform variable expansions (which may have embedded strings), command substitution (which may also have embedded strings), etc. It's impossible to correctly parse the shell with just regular expressions (i.e. without using regions), because they may overlap (_you need a recursive parser to correctly parse a shell script_).