Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighting of split #110

Closed
maros opened this issue Jan 25, 2024 · 2 comments
Closed

Highlighting of split #110

maros opened this issue Jan 25, 2024 · 2 comments

Comments

@maros
Copy link

maros commented Jan 25, 2024

The highligting of certain split statements with regular expressions is not correct.

my $string = 'aa, bb,cc, dd , ee';
my $result = [ split /\s*[,\s]\s*/, $string ];
say join ', ',$result->@*;

Screenshot 2024-01-25 at 15 40 12

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

@bscan
Copy link
Owner

bscan commented Jan 25, 2024

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: textmate/perl.tmbundle#32

Regexes don't start after split: textmate/perl.tmbundle#27 textmate/perl.tmbundle#28, textmate/perl.tmbundle#45,

Regexes don't start after grep: textmate/perl.tmbundle#21

Regexes don't start after =: textmate/perl.tmbundle#52, textmate/perl.tmbundle#44

Regexes incorrectly trigger on //= on newlines: textmate/perl.tmbundle#29

Regexes don't start after !: richterger/Perl-LanguageServer#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.

@bscan
Copy link
Owner

bscan commented Jan 30, 2024

Hi @maros, this is now resolved.

image

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:
image

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:

image

@bscan bscan closed this as completed Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants