Skip to content

PowerShell Extension Comment Highlighting Error #36924

@thomasrayner

Description

@thomasrayner

There's syntax highlighting as part of the PowerShell extension to indicate comments. It serves to highlight comments in green. The highlighting looks for a pattern of (?<![\\-])# to detect the start of a comment. In PowerShell, backtick is the escape character, and can be used to treat the # character as a literal character instead of the start of a comment. The regular expression that detects comments doesn't take this into account.

Code to reproduce

(($message.description | Select-Object -ExpandProperty `#cdata-section) -replace '(<\/*\w+?>){1,}','').trim()

Result of code

image
This line has incorrect syntax highlighting. The backtick should escape the # and negate the syntax highlighting that colors the remainder of the line green.

Possible fix

The regular expression in the PowerShell syntax tmlanguage file can be changed:

Adding the backtick character would resolve this issue, and then the pattern would be (?&lt;![\-])#`.

Results after applying fix

image

I'm planning on submitting a PR to fix this after submitting this issue.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions