Skip to content

Fix PowerShell highlighting of built-in constant variables#298570

Closed
o-l-a-v wants to merge 1 commit intomicrosoft:mainfrom
o-l-a-v:fix/powershell-highlight-constant-built-in-variables
Closed

Fix PowerShell highlighting of built-in constant variables#298570
o-l-a-v wants to merge 1 commit intomicrosoft:mainfrom
o-l-a-v:fix/powershell-highlight-constant-built-in-variables

Conversation

@o-l-a-v
Copy link

@o-l-a-v o-l-a-v commented Mar 1, 2026

Related PowerShell/EditorSyntax PR: PowerShell/EditorSyntax#223

Fix

Use a TextMate scope for PowerShell built-in constant variables that most themes actually have defined in tokenColors.

I see that C#, Ruby and Go TextMate files uses variable.other.constant.<language>, so I went with that.

Context

For a long time, PowerShell highlighting for built-in constant variables has been broken in VSCode.

image

Some related issues:

I believe I've tracked it down to the PowerShell TextMate using a TextMate scope most themes do not have a definition for:

image

The official Dracula theme even has a workaround just for this https://github.com/dracula/visual-studio-code/blob/main/src/dracula.yml:

  - name: Powershell constants mistakenly scoped to `support`, rather than `constant` (edge)
    scope:
    - support.constant
    settings:
      fontStyle: normal
      foreground: *PURPLE

@alexr00
Copy link
Member

alexr00 commented Mar 3, 2026

Thank you for the PR! We pull our grammars in from the upstream repos via script. We'd prefer to wait until PowerShell/EditorSyntax#223 gets merged and then update our grammar as usual.

@alexr00 alexr00 closed this Mar 3, 2026
@o-l-a-v o-l-a-v deleted the fix/powershell-highlight-constant-built-in-variables branch March 3, 2026 09:25
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.

3 participants