Closed maros closed 8 months ago
Thanks @maros! I think this is the most important Perl syntax highlighting issue in Perl textmate grammars. I'll elaborate:
There are a fixed set of words and characters that will start a regex if followed by a slash. Some examples (using github highlighting since it uses the same grammars):
print "good" if /foo/;
print "good" unless /foo/;
print "good" if( /foo/ && /bar/ || /baz/ );
my $result = [ split /foo/, $string ]; # Broken highlighting
This is because of one TextMate line that specifies that /
regexes start after (|{~$
, newline, and if/unless. That line is shown here:
https://github.com/textmate/perl.tmbundle/blob/a85927a902d6e5d7805f56a653f324d34dfad53a/Syntaxes/Perl.plist#L1174
That single line of TextMate generates lots of issues. Examples:
Regexes start after &&
but not after and
: https://github.com/textmate/perl.tmbundle/issues/32
Regexes don't start after split
: https://github.com/textmate/perl.tmbundle/issues/27 https://github.com/textmate/perl.tmbundle/issues/28, https://github.com/textmate/perl.tmbundle/issues/45,
Regexes don't start after grep
: https://github.com/textmate/perl.tmbundle/issues/21
Regexes don't start after =
: https://github.com/textmate/perl.tmbundle/issues/52, https://github.com/textmate/perl.tmbundle/issues/44
Regexes incorrectly trigger on //= on newlines: https://github.com/textmate/perl.tmbundle/issues/29
Regexes don't start after !
: https://github.com/richterger/Perl-LanguageServer/issues/192
I think a great start for improving syntax highlighting would be overriding the default highlighting and fixing just this one line. TextMate grammars will never be perfect, but this would be a great start.
Hi @maros, this is now resolved.
In addition to highlighting regexes correctly after split
, it should also be fixed for all the other outstanding issues I mentioned above as well.
Some examples:
Additionally, I made a variety of other fixes while I was in there. For example, although %hash
is a valid perl variable, hashes don't interpolate in strings or regex, unless a value is accessed. Other bug fixes as well shown below:
The highligting of certain split statements with regular expressions is not correct.
perl-navigator 0.5.1 2023-01-16 vscodium 1.85.1 perl v5.38.0
added this ticket just for reference once you decide to override default syntax highlighting