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

Wrongly colored perl expression #21

Open
aeschli opened this issue Aug 4, 2016 · 4 comments
Open

Wrongly colored perl expression #21

aeschli opened this issue Aug 4, 2016 · 4 comments

Comments

@aeschli
Copy link
Contributor

aeschli commented Aug 4, 2016

From @pcherkasova on June 6, 2016 21:53

  • VSCode Version: 1.1.1
  • OS Version: mac os

Steps to Reproduce:

image

Copied from original issue: microsoft/vscode#7270

@aeschli
Copy link
Contributor Author

aeschli commented Aug 4, 2016

@pcherkasova Can you paste the full snippet?

@aeschli
Copy link
Contributor Author

aeschli commented Aug 4, 2016

From @pcherkasova on June 16, 2016 23:25

Here you are:

sub parse_name {
my ($f, $m, $l, $s) = (undef, undef, undef, undef);
{
my $x = $[0];
last unless defined $x;
$x =~ s/\s
(['-])\s_/$1/g;
my @p = grep /^./, split /[^[:alpha:]'-]/i, $x;
last unless scalar @p;
$s = pop @p if $p[$#p] =~ /^(I|II|III|IV|V|Jr|Sr)$/i;
last if scalar @p == 0;
$f = $p[0], last if scalar @p == 1;
my $mp;
for (my $i = $#p - 1; $i >= 0; $i--) {
$mp = $i, last if length $p[$i] == 1;
}
if (!defined $mp) {
($f, $l) = ($p[0], (join ' ', @p[1 .. $#p]));
}
elsif ($mp == 0) {
if (scalar @p > 2) {
($f, $m, $l) = ($p[0], $p[1], (join ' ', @p[2 .. $#p]));
}
else {
($f, $l) = @p;
}
}
else {
($f, $m, $l) = ((join ' ', @p[0 .. $mp - 1]), $p[$mp], (join ' ', @p[$mp + 1 .. $#p]));
}
}
($f, $m, $l, $s);
}

[cid:98af86f9-e187-4937-82e2-4b1f42fd60ab]


From: Martin Aeschlimann [email protected]
Sent: Wednesday, June 15, 2016 12:18 PM
To: Microsoft/vscode
Cc: pcherkasova; Mention
Subject: Re: [Microsoft/vscode] Wrongly colored perl expression (#7270)

@pcherkasovahttps://github.com/pcherkasova Can you paste the full snippet?

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/microsoft/vscode/issues/7270#issuecomment-226291528, or mute the threadhttps://github.com/notifications/unsubscribe/ALjegk93Vsxvy65osD51geUidZ14JVU5ks5qMFAVgaJpZM4IvWwB.

@chrstphrchvz
Copy link

@pcherkasova This looks caused by the combination of the // match operator in split /[^[:alpha:]'-]/i and the ' (single quote) that appears inside of it, resulting in everything that follows it to be highlighted as a string color until the next '. (The contents of the ' ' strings in join ' ' on the following lines are actually not highlighted as a string.)

One workaround is to use m// instead of //, i.e. split m/[^[:alpha:]'-]/i.

I have no insight as to how to fix this though.

@peternewman
Copy link

Here's another use case where it needs m// in split, but only in some cases:

my ($b) = split /-/, $a;
foo();
my ($c) = split /__DATA_/, $a;
bar1();
my ($d) = split /_DATA__/, $a;
bar2();
my ($e) = split m/__DATA__/, $a;
baz1();
my ($f) = split /__DATA__/, $a;
baz2();

Note how baz2() (and everything after the second __DATA__ is formatted as a comment here on GitHub.

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

3 participants