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

Label in front of Foreach, For, and While loop keyword is not highlighted #89

Open
kborowinski opened this issue May 8, 2018 · 2 comments

Comments

@kborowinski
Copy link
Contributor

Environment

> code-insiders.cmd -v
1.24.0-insider
d29620f2ba89327f51bb6fb2f05dfdd65e2fcafe

> $psEditor.EditorServicesVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
1      7      0      0

> code-insiders.cmd --list-extensions --show-versions
...
ms-vscode.PowerShell@1.7.0
...

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.17134.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Label in front of Foreach, For, and While loop is not highlighted:

image

Expected Behavior

Label should be highlighted

@omniomi
Copy link
Collaborator

omniomi commented May 8, 2018

Looks like the loop constructs are also not defined. Currently it's inheriting from:

<keyword match> <interpolatedStringContent> <
    scriptblock
>

Which is for obvious reasons not ideal. Will work something out tonight :)

@msftrncs
Copy link
Contributor

@kborowinski, PR #156 demonstrates handling of label, but I made up a scope to assign to it, so without some support in the theme, it will still appear unhandled.

Anyone have any recommendations for scope for a label? I used 'entity.name.label.powershell' for both definition and use.

A caution: Labels also can be valid function names. TextMate is not sophisticated enough to handle all the possible situations that can arise, so PR #156 is confined to consider any construct that might be a valid label, as a label, if its the only thing that appears on the rest of the statement line. TextMate cannot make scoping decisions spanning more than one line; all decisions must be final at the end of the line.

FYI, in the code shown, the label is probably unneeded, as is the FOREACH loop, as SWITCH automatically performs expansion of a collection (but the result variable will be $_). Also, you might be interested to know, that quotes are not needed around the test value in SWITCH statements, when they are a simple word. The 'Subject' and 'Body' can be Subject and Body.

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

3 participants