jeff-hykin / better-perl-syntax

💾 An improvement to the perl syntax for VS Code
MIT License
5 stars 3 forks source link

Syntax highlight of unmodified s{}{} with postfix IF bleeds into next line. #11

Open NorthboundTrain opened 3 years ago

NorthboundTrain commented 3 years ago

The following code:

$opts->{'mockurl'} =~ s{^https}{http} if $opts->{'http'};

#----- clear out test directory -----
rmtree($opts->{'jobdir'});

results in:

Screen Shot 2021-03-25 at 9 12 53 AM

However, if I change s{}{} to s/// then it works fine.

Screen Shot 2021-03-25 at 9 15 32 AM

even adding a modifier to s{}{} (e.g. s{}{}i) will fix it:

Screen Shot 2021-03-25 at 9 17 01 AM

And any of these without the postfix if works just fine:

Screen Shot 2021-03-25 at 9 20 17 AM

Thanks!

shames0 commented 2 years ago

I'm seeing the same behavior for a non postfix-IF (but still an IF)

#!/usr/bin/env perl

my $foo = "stuff to change";
if ($foo =~ s{change$}{celebrate}) {
    # this is not highlighed like a comment should be
    print $foo;
    foreach my $x qw(a b c d e f g) {
        print $x
    }
}

results in image

changing s{}{} to s/// allows highlighting to behave properly image

adding modifier image