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

PowerShell Highlighter miscategorises typecasts and braced variables #1025

Closed
vexx32 opened this issue Oct 30, 2018 · 3 comments
Closed

PowerShell Highlighter miscategorises typecasts and braced variables #1025

vexx32 opened this issue Oct 30, 2018 · 3 comments

Comments

@vexx32
Copy link

vexx32 commented Oct 30, 2018

The following two PowerShell language tokens are improperly parsed:

  1. [ObjectType] type or type cast tokens. These may have embedded type tokens as well:
[System.Collections.Generic.List[string]](1..100)
[System.Collections.Generic.Dictionary[string, int]](1..100|%{@{N=$_}})

Currently, the sequence [List[int]] is broken up and highlighted as:

  • [ - operator
  • List[int]] - no recognised special token (yes, that includes the matching closing bracket)

In typical PowerShell highlights, the entire type cast token is a single color, or else the brackets are a different color with the text inside a single coherent color -- but matching brackets are always coloured the same, whereas with default highlighting settings, Rouge instead only colors the opening bracket and nothing else.

  1. ${Braced Variables} -- within the ${ } boundary, any character at all is treated as a valid variable character, regardless of whether it is normally a legal variable name character or not.

Currently a braced variable with a scope specifier, e.g. ${function:mkdir} is parsed as:

  • ${ - keyword
  • function - Name.Variable
  • :mkdir - Unrecognised / no highlighting
  • } - keyword

Instead, the whole token ${function:mkdir} ought to be treated as a single variable token in PowerShell code.

Although I have not yet had a chance to test for certain, I suspect similarly-written scope modifiers such as $global:ErrorActionPreference may be similarly split-highlighted.

@aaroneg
Copy link
Contributor

aaroneg commented Jun 28, 2019

@pyrmont was this one fixed by that PR as well?

@pyrmont
Copy link
Contributor

pyrmont commented Jun 28, 2019

@aaroneg Thanks for pinging me!

@vexx32 This should be fixed with the new PowerShell lexer that was merged via #1213. Your examples look good to me but please let us know if you're still having problems. Sorry it took so long! >_<

@pyrmont pyrmont closed this as completed Jun 28, 2019
@vexx32
Copy link
Author

vexx32 commented Jun 28, 2019

Not at all, thank you guys for taking care of it! 😊

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

3 participants