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 problems after /\|/ #28

Open
aeschli opened this issue Jan 11, 2018 · 5 comments
Open

highlighting problems after /\|/ #28

aeschli opened this issue Jan 11, 2018 · 5 comments

Comments

@aeschli
Copy link
Contributor

aeschli commented Jan 11, 2018

From @schuan01 on December 29, 2017 14:58

Steps to Reproduce:

  1. Copy the code after this steps in a new file.
  2. See the bad coloring(all red) after "my @linea = split /|/, $LINEA;"

---- EXAMPLE CODE ---

my $LINEA = $_;
	chomp( $LINEA );
	my @LINEA = split /\|/, $LINEA;
	
	$HOJATNO++;

	# creamos el lote
	if ( not ref $LOTE_REF ) {
		#Supongo que 
		my ( $EMISION, $ORDEN, $LOTE) = ( $LINEA[$POS_EMISION], $LINEA[$POS_ORDEN], $LINEA[$POS_LOTE] );
		
		$LOTE_REF = CE::Lote->new(-lote => $LOTE, -ambiente => $AMBIENTE, -cliente => $CLIENTE, -trabajo => $TRABAJO,-emision => $EMISION, -orden => $ORDEN );
	}
	
	#Leo datos que necesito
	my ( $SPOOL, $INTERNO, $HOJA ) = ( $LINEA[$POS_SPOOL], $LINEA[$POS_INTERNO], $LINEA[$POS_HOJA] );
	my ( $IMPRIME, $GENERA, $VISUALIZA ) = ($LINEA[$POS_IMPRIME], $LINEA[$POS_GENERA], $LINEA[$POS_VISUALIZA] );
	my ( $VALOR_CRITERIO1A, $VALOR_CRITERIO1B ) = ( $LINEA[$POS_CEDULA], $LINEA[$POS_TIPORECIBO] );
	my ( $VALOR_CRITERIO2A, $VALOR_CRITERIO2B ) = ( $LINEA[$POS_NROEMPLEADO], $LINEA[$POS_TIPORECIBO] );
	my $VALOR_CRITERIO3A = $LINEA[$POS_GENERACION];

Copied from original issue: microsoft/vscode#40944

@chrstphrchvz
Copy link

@schuan01 Using m// instead of // (i.e. my @LINEA = split m/\|/, $LINEA;) seems to workaround the issue.

Based on the red highlighting, it looks as if it the second / is being treated as the start of a match operator, because it will apply that highlighting until another / or /…/ is encountered.

@chrstphrchvz
Copy link

The same example and workaround were identified as part of #27

@oscaretu
Copy link

@schuan01 Using m// instead of // (i.e. my @LINEA = split m/\|/, $LINEA;) seems to workaround the issue.

That solution doesn't seem to be a good one. Nobody uses split m/.../ because the official documentation doesn't show that syntax as valid (I didn't check if Perl admits it, but if @schuan01 suggested that workaround I suppose that his Perl version didn't complain):

oscar@toreyes-i7:~$ perldoc -f split
    split /PATTERN/,EXPR,LIMIT
    split /PATTERN/,EXPR
    split /PATTERN/
    split   Splits the string EXPR into a list of strings and returns the list
            in list context, or the size of the list in scalar context.
     ....
     ...

It makes no sense to have to modify pre-existing source code just to have VSCode correctly display the colored syntax.

@oalders
Copy link

oalders commented Jul 18, 2022

Nobody uses split m/.../

https://grep.metacpan.org/search?q=split+m&qd=&qft=

It makes no sense to have to modify pre-existing source code just to have VSCode correctly display the colored syntax.

It's not a solution, but as a workaround until the syntax highlighting is fixed, it's a helpful suggestion.

@chrstphrchvz
Copy link

chrstphrchvz commented Jul 18, 2022

@schuan01 Using m// instead of // (i.e. my @LINEA = split m/\|/, $LINEA;) seems to workaround the issue.

That solution doesn't seem to be a good one. Nobody uses split m/.../ because the official documentation doesn't show that syntax as valid

See perlop section “m/PATTERN/…” under “Regexp Quote-Like Operators”, specifically the part about how:

If "/" is the delimiter then the initial m is optional.

This has been the case at least since Perl 5.0.

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

4 participants