SublimeText / PowerShell

Support for the MS PowerShell programming language.
MIT License
312 stars 80 forks source link

Syntax highlight breaks on -Keyword parameter name #157

Closed nanoant closed 6 years ago

nanoant commented 6 years ago

When function parameter name is a keyword e.g. -Function then the syntax grammar gets confused, see example below for correct PowerShell script syntax with broken highlighting.

Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

function Prompt {
    Write-Host "[$(Get-Date -Format HH:mm:ss)] " -NoNewline -ForegroundColor Gray
    Write-Host $(Get-Location) -ForegroundColor Cyan
    return '> '
}

P.S. Even GitHub highlight breaks here :)

image

vors commented 6 years ago

Thank you for the bug report! Indeed: github uses this grammar, very convenient for repros :)

xse commented 6 years ago

Hi ! I have the same issue here :

2018-03-05 22_03_36-c__users_elouan_documents_windowspowershell_microsoft powershell_profile ps1 -

As soon as i put a "(" after the buggy string it disappear :)

2018-03-05 22_05_25-c__users_elouan_documents_windowspowershell_microsoft powershell_profile ps1 -

Have a good day !

vors commented 6 years ago

Looks like https://github.com/PowerShell/EditorSyntax handles it correctly. We are planning to switch to their grammar soon. Stay tuned.