Skip to content

Wrong syntax highlighting when using \. in regex inside HEREDOC #102958

@lucasbasquerotto

Description

@lucasbasquerotto
  • VSCode Version: 1.47.1
  • OS Version: Linux x64 5.3.0-62-generic snap (Ubuntu 18.04)

Steps to Reproduce:

  1. Paste the below code:
#!/bin/bash

cat <<SHELL > /path/file2
	if [[ "$myvar" =~ ^(([0-9]|[1-9])\.)$ ]]; then
		echo "test"
	fi
SHELL
  1. Verify that the closing SHELL is highlighted as a string (not with the same color as the starting SHELL), and from there on till the end of the file (if there is more content), the highlight will consider the code as if it was inside the HEREDOC (even tough it isn't).

This does not happen if I remove \. from the regex (but this changes what it does):

#!/bin/bash

cat <<SHELL > /path/file2
	if [[ "$myvar" =~ ^(([0-9]|[1-9]))$ ]]; then
		echo "test"
	fi
SHELL

This also doesn't happen if I wrap \. with brackets (it's the current workaround I'm using):

#!/bin/bash

cat <<SHELL > /path/file2
	if [[ "$myvar" =~ ^(([0-9]|[1-9])(\.))$ ]]; then
		echo "test"
	fi
SHELL

Metadata

Metadata

Assignees

Labels

grammarSyntax highlighting grammarupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions