mirror of
https://github.com/Microsoft/vscode
synced 2024-07-05 01:08:57 +00:00
Merge pull request #210901 from microsoft/tyriar/210783_2
Fix replacing of ESC in pwsh
This commit is contained in:
commit
ad5ae83b39
|
@ -52,17 +52,12 @@ if ($env:VSCODE_ENV_APPEND) {
|
|||
function Global:__VSCode-Escape-Value([string]$value) {
|
||||
# NOTE: In PowerShell v6.1+, this can be written `$value -replace '…', { … }` instead of `[regex]::Replace`.
|
||||
# Replace any non-alphanumeric characters.
|
||||
$Result = [regex]::Replace($value, '[\\\n;]', { param($match)
|
||||
[regex]::Replace($value, "[$([char]0x1b)\\\n;]", { param($match)
|
||||
# Encode the (ascii) matches as `\x<hex>`
|
||||
-Join (
|
||||
[System.Text.Encoding]::UTF8.GetBytes($match.Value) | ForEach-Object { '\x{0:x2}' -f $_ }
|
||||
)
|
||||
})
|
||||
# `e is only availabel in pwsh 6+
|
||||
if ($PSVersionTable.PSVersion.Major -lt 6) {
|
||||
$Result = $Result -replace "`e", '\x1b'
|
||||
}
|
||||
$Result
|
||||
}
|
||||
|
||||
function Global:Prompt() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user