Issue Type: Bug
_I originally raised this issue in the vsc repo but it was closed as deemed to be a PS extension issue so re-raising here._
Visual Studio Code's syntax highlighting for PowerShell appears to be broken for functions - the code blocks initially have syntax highlighting but then they turn grey after some time. It feels like the issue is directly related to loading references, as highlighting works at first until references are attempted to be loaded (typically within 20 seconds or so)

Extension version: 2019.11.0
VS Code version: Code 1.40.0 (86405ea23e3937316009fc27c9361deee66ffbf5, 2019-11-06T17:02:13.381Z)
OS version: Windows_NT x64 10.0.18362
System Info
|Item|Value|
|---|---|
|CPUs|Intel(R) Xeon(R) CPU E3-1240 v5 @ 3.50GHz (8 x 3504)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|15.93GB (4.37GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|
We don't do any deliberate highlighting changes and VSCode's syntax highlighting is done separately to the extension.
However, I'm wondering if this is a smaller bug of ours (the references issue) colliding with something in VSCode. Maybe you could try disabling CodeLens and seeing if that changes anything:
"[powershell]": {
"editor.codeLens": false
}
@SimonHounsell would you be able to post the text of your profile that you captured in that image? I'll see if I can reproduce the behaviour with it.
"[powershell]": { "editor.codeLens": false }
Disabling CodeLens removes the references and the syntax highlighting works as expected. Re-enabling CodeLens shows the references and the syntax highlighting breaks again.
Ok, so we've confirmed that it's references. But I don't know why that would hit syntax highlighting. I'm reasonably certain we don't do any extra manipulation there (you have to really go out of your way to change highlighting beyond a grammar in VSCode).
Hopefully the VSCode team can assist us with this.
@SimonHounsell would you be able to post the text of your profile that you captured in that image? I'll see if I can reproduce the behaviour with it.
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
Clear-Host
$DefaultUser = "s.hounsell"
$HartsCoreDir = "D:\Dev\repos\HartsCore\InfoTrack.Harts.Core"
$CoreProjectPath = "$HartsCoreDir\InfoTrack.Harts.Core.csproj"
function EditProfile { code $profile }
function reload { . $PROFILE }
function repos { Set-Location -Path D:\Dev\repos }
function a { Set-Location -Path D:\Dev\repos\Automation }
function f { Set-Location -Path D:\Dev\repos\ForWard }
function hc { Set-Location -Path $HartsCoreDir }
function hf { Set-Location -Path D:\Dev\repos\HartsFrontEnd }
function hi { Set-Location -Path D:\Dev\repos\HartsInfrastructure }
function hl { Set-Location -Path D:\Dev\repos\HartsLambda }
function hs { Set-Location -Path D:\Dev\repos\HartsSync\InfoTrack.Harts.Sync }
function Core-Run {
dotnet build $CoreProjectPath
dotnet run --project $HartsCoreDir
}
function Core-Update { dotnet ef database update --context HartsCoreContext --project $HartsCoreDir }
function Core-Pull {
$CurrentLocation = Get-Location
Set-Location $HartsCoreDir
git checkout develop
git pull
git clean -fdx
Set-Location $CurrentLocation
}
function Core-PullAndUpdate {
Core-Pull
Core-Update
}
function Core-PullUpdateRun {
Core-PullAndUpdate
Core-Run
}
function Core-MergeLatest {
# Logically:
# 1. Check it's a valid git directory
# 2. Check it's not the develop or master branches
# 3. Stash changes if there are any
# 4. Checkout develop
# 5. PullAndUpdateCore
# 6. Checkout the starting branch
# 7. Merge develop into the current branch
# a. Could get merge conflicts at this stage
# 8. Unstash changes if there were any stashed at step 3
# a. Could get merge conflicts at this stage
# 9. Switch back to the starting directory
$ErrorActionPreference = "Stop"
$CurrentLocation = Get-Location
Set-Location $HartsCoreDir
$GitBranch = cmd /c git branch --show-current '2>nul'
if (!$GitBranch) {
Write-Error "Current directory is not a git directory."
}
if ($GitBranch -Eq "master" -Or $GitBranch -Eq "develop") {
Write-Error "Cannot merge develop when checked out branch is either master or develop. Current checked out branch is $GitBranch."
}
$GitStatus = git status -s
if ($GitStatus) {
git stash
Write-Output "Stashed changes"
}
Core-PullAndUpdate
git checkout $GitBranch
git merge develop
if ($GitStatus) {
git stash pop
Write-Output "Unstashed changes"
}
Set-Location $CurrentLocation
}
Ok I'm also not experiencing the issue on my machine.
There are a couple of things to look into:
code --list-extensions should provide that list)powershell extension and install powershell-preview?Based on what you're saying about the highlighting still appearing in the clipboard, I'm suspicious that this may be an issue within VSCode that the PowerShell extension just brings to light in some way.
- What other extensions are installed? (
code --list-extensionsshould provide that list)
I couldn't get the code --list-extensions command to work, it just opens a new instance of VSC, so I've copied the auto-generated extension list from the first issue I opened:
Extensions (27)
Extension|Author (truncated)|Version
---|---|---
ng-template|Ang|0.802.3
gitlens|eam|10.1.2
vscode-html-css|ecm|0.2.3
EditorConfig|Edi|0.14.2
tslint|eg2|1.0.44
dotnet-test-explorer|for|0.7.1
vscode-angular-html|gha|1.3.1
vscode-pull-request-github|Git|0.12.0
vscode-test-explorer|hbe|2.14.6
csharpextensions|jch|1.3.1
docomment|k--|0.1.8
auto-comment-blocks|kev|1.0.1
dotnet-core-essentials|Kis|0.0.8
typelens|kis|1.9.2
vscode-docker|ms-|0.8.2
python|ms-|2019.10.44104
csharp|ms-|1.21.6
powershell|ms-|2019.11.0
vscode-typescript-tslint-plugin|ms-|1.2.2
vsliveshare|ms-|1.0.1123
debugger-for-chrome|msj|4.12.1
vscode-css-peek|pra|3.0.2
angular-karma-test-explorer|raa|1.2.3
vscode-yaml|red|0.5.3
comment-ts|sal|0.9.11
vscode-scss-formatter|sib|1.4.2
html-css-class-completion|Zig|1.19.0
- Does this happen if you change to VSCode Insiders?
No it does not happen in VSCode Insiders with the PowerShell extension installed. Note: I've just installed VSCode Insiders and have only installed the PowerShell extension.
- Does this happen if you use the unload the
powershellextension and installpowershell-preview?
Yes it does happen in VSCode (standard) with the PowerShell extension disabled and the PowerShell Preview extension installed.
So I've just made a discovery. It appears to be the TypeLens extension which is causing the issue, or in combination with the PowerShell extension. Can you install TypeLens and see if you can re-create the issue?
Yep that reproduces the issue instantly, including for the PowerShell preview extension
Closing this since the TypeLens extension has a way to deal with this