Skip to content

Commit

Permalink
Merge pull request #170516 from andschwa/andschwa/shell-integration
Browse files Browse the repository at this point in the history
Fix shell integration for PowerShell 5.1
  • Loading branch information
Tyriar committed Jan 12, 2023
2 parents b7f4d34 + 6313d41 commit 7e54126
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ function Global:__VSCode-Escape-Value([string]$value) {
[regex]::Replace($value, '[\\\n;]', { param($match)
# Encode the (ascii) matches as `\x<hex>`
-Join (
[System.Text.Encoding]::UTF8.GetBytes($match.Value)
| ForEach-Object { '\x{0:x2}' -f $_ }
[System.Text.Encoding]::UTF8.GetBytes($match.Value) | ForEach-Object { '\x{0:x2}' -f $_ }
)
})
}

function Global:Prompt() {
# NOTE: We disable strict mode for the scope of this function because it unhelpfully throws an
# error when $LastHistoryEntry is null, and is not otherwise useful.
Set-StrictMode -Off
$FakeCode = [int]!$global:?
$LastHistoryEntry = Get-History -Count 1
# Skip finishing the command if the first command has not yet started
Expand Down

0 comments on commit 7e54126

Please sign in to comment.