Skip to content

Version v2021.2.2 doesn't highlight the #Requires statements #3211

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

Open
vivere-dally opened this issue Feb 26, 2021 · 8 comments
Open

Version v2021.2.2 doesn't highlight the #Requires statements #3211

vivere-dally opened this issue Feb 26, 2021 · 8 comments
Assignees

Comments

@vivere-dally
Copy link

Environment

  • Editor and Version (VS Code, Atom, Sublime): VSCode 1.53.2
  • Your primary theme: Dark+ (default dark)

Issue Description

I just opened some PowerShell scripts and the extension got updated. Right in front of my eyes, I had some #requires statements and they got their highlight stripped off.

Screenshots

image

Expected Behavior

image

The only Theme which still highlights those statements that I found is Night Owl. I have like 10 themes installed and went through all of them and the Night Owl is the only one.

Code Samples

# Az modules
#Requires -Module @{ ModuleName = 'Az.Accounts'; RequiredVersion = '1.9.5' }
#Requires -Module @{ ModuleName = 'Az.ApplicationInsights'; RequiredVersion = '1.1.0' }
#Requires -Module @{ ModuleName = 'Az.Compute'; RequiredVersion = '4.5.0' }
#Requires -Module @{ ModuleName = 'Az.Network'; RequiredVersion = '3.5.0' }
#Requires -Module @{ ModuleName = 'Az.Resources'; RequiredVersion = '2.5.1' }
#Requires -Module @{ ModuleName = 'Az.ServiceBus'; RequiredVersion = '1.4.1' }
#Requires -Module @{ ModuleName = 'Az.Storage'; RequiredVersion = '2.7.0' }
#Requires -Module @{ ModuleName = 'Az.Websites'; RequiredVersion = '1.11.0' }
@TylerLeonhardt
Copy link
Member

EditorSyntax is no longer used in VS Code when you have the PowerShell extension installed. It uses a feature called "Semantic Highlighting" that provides better accuracy overall. Unfortunately that doesn't handle #Requires yet.

@rjmholt @andschwa can you transfer this issue to vscode-powershell?

@rjmholt rjmholt transferred this issue from PowerShell/EditorSyntax Feb 26, 2021
@ghost ghost added the Needs: Triage Maintainer attention needed! label Feb 26, 2021
@msftrncs
Copy link

msftrncs commented Mar 2, 2021

EditorSyntax is no longer used in VS Code when you have the PowerShell extension installed.

Incorrect. Unless your theme is marked as supporting semantic highlighting, you will 100% use the EditorSyntax grammar highlighting. (this is what the OP is running in to) Secondly, anything the symantic highlighting doesn't handle directly, falls back to the EditorSyntax grammar highlighting.

Third, semantic highlighting was not intended to be a replacement for TextMate grammar's, but instead a supplement. TextMate is still going to handle things better and be more flexible. In the case of PowerShell, the symantic highlighter is almost useless, as everything can be determined by the TextMate grammar. I am not implying that the current EditorSyntax grammar handles everything, but that a TextMate grammar CAN handle everything PowerShell has to syntax, which so implemented.

My suggestion, STOP semantically highlighting comments, and let that fall back on the TextMate grammar.

Include in that Text Strings, as the semantic highlighting prevents the TextMate grammar from highlighting character escapes. (actually the sematic highlighting will fail on a text string (doublequote) if an intepolated variable appears, so it should just give up trying text strings in general.)

@SydneyhSmith
Copy link
Collaborator

Thanks everyone, we agree that we should mark comments so that they are not semantically highlighted, and fall back to the TextMate grammar

@SydneyhSmith SydneyhSmith added Area-Semantic Highlighting Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! labels Mar 2, 2021
@andyleejordan andyleejordan self-assigned this Mar 3, 2021
@andyleejordan andyleejordan added this to the Consider-vNext milestone Mar 3, 2021
@JeeBee14
Copy link

JeeBee14 commented Mar 4, 2021

There is also an issue where the methods are the same color as the variable which is calling the method. The code is very hard to read in general. I'm also using the Dark+ theme.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 4, 2021
@GreatTeacherBasshead
Copy link

#3220

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 9, 2021
@andyleejordan
Copy link
Member

As a workaround until semantic highlighting improves enough, you can disable it: #3221 (comment)

@Cohors1316
Copy link

Other issue I've had with the semantic highlighting are $true / $false / $null / $Script: etc.

I feel like there should be a general catch all issue for highlighting at it's current state. I'd rather not spam issues with every semantic issue I find.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 25, 2021
@SydneyhSmith
Copy link
Collaborator

@Cohors1316 good suggestions we will use #3221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants