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

Color coding problem when using [ValidateScript({Test-Path "${_}`:\" -PathType Container})] #225

Closed
pmcelreavy opened this issue Jul 13, 2016 · 7 comments

Comments

@pmcelreavy
Copy link

pmcelreavy commented Jul 13, 2016

I use the following code to test the if the driver letter exists (sorry I can't figure out how to format it correctly due to the apostrophe):

[ValidateScript({Test-Path "${_}`:\" -PathType Container})]
[string]$DeploymentDriveLetter

And because of {} and ` color coding gets all out of whack in the IDE. You'll notice that most of the code afterwards is considered a string. This used to work at least 2-3 versions ago.

@daviwil
Copy link
Contributor

daviwil commented Jul 13, 2016

@gravejester, do you know if your PR resolves this?

@LaurentDardenne
Copy link

LaurentDardenne commented Jul 18, 2016

Same problem, but with different source code :

Function zero { 
   Write-Host "Test"
  #$New."$($_.Name)"=$Old."$($_.Name)"
} #zero 

Function One { 
 param (
  $Old,
  $New=$null
 ) 

 if ($New -eq $null) 
 { $New=New-MyOptions }

 $Old.PSObject.Properties.Match("*","Property")|
  Foreach {
      # The following line break the PS syntax highlighting 
    $New."$($_.Name)"=$Old."$($_.Name)"
  } 
 $New
} #One 

Function Two { 
  param (
    [Parameter(Position=0, Mandatory=$True)]
    [ValidateNotNullOrEmpty()]
   [int] $Options
  )
  [void](One  $Options $Script:Default)
} #Two

vscodeps-syntax highlighting

@LaurentDardenne
Copy link

Another case :

function Add-ManageResources{
 param (
  [string] $SourceName
 )
Write-Debug "Add-ManageResources $SourceName.resources" 

@"

`$ResourcesPath= Join-Path `$ScriptPath "$SourceName.resources"
if ( !(Test-Path `$ResourcesPath))
{
  Write-Error `"$($TransformMsgs.ManageResourcesError)`"
  break; 
}
  $($TransformMsgs.ManageResourcesComment)
`$Reader = new-Object System.Resources.ResourceReader(`$ResourcesPath)
`$Resources=@{}
`$Reader.GetEnumerator()|% {`$Resources.(`$_.Name)=`$_.value}

 $($TransformMsgs.CreateComponentComment)
"@         
}#Add-ManageResources

function Add-ManagePropertiesResources {
 param (
  [string] $SourceName
 )
Write-Debug "Add-ManagePropertiesResources $SourceName.resources"

 #...               
}#Add-ManagePropertiesResources

@rkeithhill
Copy link
Contributor

I wonder if this feature request for VSCode would be a better long term answer for PowerShell colorization.

@daviwil
Copy link
Contributor

daviwil commented Jul 18, 2016

A discussion has been started about adding syntax highlighting support to the language service API but I'm not sure when it'll happen. Seems like it'll happen eventually though.

@LaurentDardenne
Copy link

vsccode 1.4 fix these problems.
Thank you :-)

@pmcelreavy
Copy link
Author

I can confirm, my issue has been resolved.

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

4 participants