Skip to content

lsh: Fix PowerShell commands and operators matching keyword rules - #999

Open
Jae Birdsall (jaeminbird) wants to merge 1 commit into
microsoft:mainfrom
jaeminbird:fix-powershell-cmdlet-highlighting
Open

Jae Birdsall (jaeminbird) wants to merge 1 commit into
microsoft:mainfrom
jaeminbird:fix-powershell-cmdlet-highlighting

Conversation

@jaeminbird

Copy link
Copy Markdown

The keyword rules ran before the command rule, so cmdlets whose verb starts with a keyword were mis-highlighted: ForEach-Object showed ForEach as a keyword, and Format-Table, Invoke-WebRequest and Install-Module got no highlight at all. The in of -in was also highlighted as a keyword.

This matches Verb-Noun commands and -operator/-Parameter tokens before the keyword rules.

  • lsh render of the existing powershell.ps1 sample is byte-identical before and after.
  • Added the cases above to assets/highlighting-tests/powershell.ps1.
  • cargo test --workspace and clippy -D warnings pass.

Commands like ForEach-Object, Format-Table or Invoke-WebRequest were matched by the keyword rules before the command rule, so they were highlighted partially as a keyword or not at all. The same happened to the "in" of the -in operator. Match commands and -operators before keywords.
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

Successfully merging this pull request may close these issues.

1 participant