PowerShell / EditorSyntax

PowerShell syntax highlighting for editors (VS Code, Atom, SublimeText, TextMate, etc.) and GitHub!
MIT License
132 stars 43 forks source link

syntax highlighting of powershell (ps1) files #63

Closed aeschli closed 6 years ago

aeschli commented 6 years ago

From @dhcgn on August 31, 2016 8:11

The syntax highlighting of powershell has not working correct

Steps to Reproduce:

  1. Paste this code in vscode and save it as *.ps1
Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
$olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
$outlook = new-object -comobject outlook.application
$namespace = $outlook.GetNameSpace("MAPI")
$folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
$folder.items | ?{$_.Subject -like "Lorem Ipsum*"} | 
 %{
    $regexResult = $_.HTMLBody | Select-String -Pattern "Lorem Ipsum: <b>(\d{1,})<\/b>" -AllMatches
    $numVirus =  $regexResult.Matches.Groups[1].Value

    $properties = @{
      'NumberVirus'=$numVirus;
      'Date'= $_.CreationTime
      }
    $object = New-Object –TypeName PSObject –Prop $properties
    $object
  } | Tee-Object -Variable result

  $result | Out-GridView
  1. You will see a few statements with none syntax highlighting. (e.g. } | Tee-Object -Variable result) image

Copied from original issue: Microsoft/vscode#11289

aeschli commented 6 years ago

From @Bill-Stewart on September 13, 2016 20:18

Have you tried the PowerShell extension?

aeschli commented 6 years ago

From @KeeperB5 on October 6, 2016 15:58

I would like to demonstrate difference in PowerShell syntax coloring between various editors. VS Code is by far the worst of the bunch. And this is with VSCode version 1.5.3 and PowerShell extension 0.7.2.

aeschli commented 6 years ago

From @daviwil on October 6, 2016 17:46

Hey @KeeperB5, we'd love to hear your thoughts over at the https://github.com/PowerShell/EditorSyntax repo where we're trying to work on improving the syntax highlighting grammar for VS Code and Atom.

One suggestion though: If you aren't currently using the "Dark+" theme in VS Code, try that out. It improves the syntax colorization somewhat because the theme has more colors than the default "Dark" theme.

The ISE and Visual Studio both have better PowerShell syntax highlighting than VS Code because they use the PowerShell engine's tokenizer instead of a regex-based colorizer as VS Code and Atom do.

aeschli commented 6 years ago

From @KeeperB5 on October 7, 2016 5:4

@daviwil VS Code is already using Dark+ theme in the VS Code image. I can certainly give more specific feedback if there is something in particular you want me to elaborate on. Looks like most common issues have already been reported in EditorSyntax issues, so I have nothing to add there. I use PowerShell Studio at work and Visual Studio Community at home, so VS Code doesn't get much attention from me, sorry.

aeschli commented 6 years ago

We now use the PowerShell/EditorSyntax grammar. The issue is still existing.

omniomi commented 6 years ago

This is resolved as of the most recent commit 529562f

fixed2

gostega commented 4 years ago

Not totally relevant but hopeully this helps someone as this was extraordinarily difficult to google for, for some reason, until I came across https://github.com/Microsoft/vscode/issues/11289 which links to this current page.

I was having an issue where variables were not highlighted in powershell, just appearing as default white colour. I tried numerous themes (installed from Extensions in VSCode) including powershell preview, nothing worked.

Switching to Dark+ as suggested here https://github.com/Microsoft/vscode/issues/11289 by daviwil on 20 Oct 2016 resolved the issue for me.

Issue: (present in Dark (Visual Studio), Monokai, One Monokai, etc. etc.) image

After switching to Dark+ (default dark), it was fixed, looking like this: image