Skip to content

Commit 975ed6c

Browse files
committed
Fix shell integration for PowerShell 5.1 with strict mode
Since `$IsWindows` doesn't exist in Windows PowerShell, with strict mode enabled and the `ErrorActionPreference` set to `Stop`, shell integration would cause the startup to crash. This was reported and fixed upstream too.
1 parent b9ae76b commit 975ed6c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,11 @@ private Task EnableShellIntegrationAsync(CancellationToken cancellationToken)
663663
}
664664
665665
# Set IsWindows property
666-
Write-Host -NoNewLine ""$([char]0x1b)]633;P;IsWindows=$($IsWindows)`a""
666+
if ($PSVersionTable.PSVersion -lt ""6.0"") {
667+
[Console]::Write(""$([char]0x1b)]633;P;IsWindows=$true`a"")
668+
} else {
669+
[Console]::Write(""$([char]0x1b)]633;P;IsWindows=$IsWindows`a"")
670+
}
667671
668672
# Set always on key handlers which map to default VS Code keybindings
669673
function Set-MappedKeyHandler {

0 commit comments

Comments
 (0)