You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ValidateScript()] highlighting very incorrect #65
function Verb-Noun{
param(
[ValidateScript({ Test-Path -Path $_ })]
[string]
$Path
)
Begin { }
Process { }
End { }
}
In about half of the themes I've looked through, and the majority of the default ones (especially the PS extension's ISE theme) there is a very glaring syntax highlight issue. Any cmdlet placed in the inline scriptblock will be highlighted in two different colours, switching colours at the dash. The closing brace will also inherit the offending colour.
Adding a line-break after the opening brace will hide the issue, but the cmdlet within the script block is then not highlighted as a cmdlet at all, either.
Some darker themes will obscure the issue, giving a similar colour pairing to the two halves of the cmdlet (e.g., Monokai Dark), but if you look you can still see the issue is present. On themes with a more restricted color palette (e.g., monochrome themes) the difference is often not noticeable.
And with this test case you will see that everything in the ValidateScript after if statements closing paren is not being highlighted (on the plus side the command within the parens is now highlighted with just one incorrect color)
function Get-Something {
[CmdletBinding()]
Param(
[ValidateScript({
if (Test-Path -Path $_) {
$true
}
else {
$message = 'Cannot access path {0} as it does not exist' -f $_
Throw $message
}
})]
[string]
$Path
)
Get-ChildItem -Path $Path
}
Screenshot:
Operating System:
ProductName Version Build UBR
----------- ------- ----- ---
Windows 10 Enterprise Evaluation 1703 15063 966
Activity
csandfeld commentedon Mar 27, 2018
And with this test case you will see that everything in the ValidateScript after if statements closing paren is not being highlighted (on the plus side the command within the parens is now highlighted with just one incorrect color)
Screenshot:

Operating System:
VSCode version:
PowerShell Editor Services Version:
VSCode Extensions:
[email protected]PowerShell Version Table:
omniomi commentedon May 21, 2018
Fixed by #94