Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace backtick-e with $([char]0x1b) #1961

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ private Task EnableShellIntegrationAsync(CancellationToken cancellationToken)
if ($Global:__LastHistoryId -ne -1) {
if ($LastHistoryEntry.Id -eq $Global:__LastHistoryId) {
# Don't provide a command line or exit code if there was no history entry (eg. ctrl+c, enter on no command)
$Result = ""`e]633;E`a""
$Result += ""`e]633;D`a""
$Result = ""$([char]0x1b)]633;E`a""
$Result += ""$([char]0x1b)]633;D`a""
} else {
# Command finished command line
# OSC 633 ; A ; <CommandLine?> ST
$Result = ""`e]633;E;""
$Result = ""$([char]0x1b)]633;E;""
# Sanitize the command line to ensure it can get transferred to the terminal and can be parsed
# correctly. This isn't entirely safe but good for most cases, it's important for the Pt parameter
# to only be composed of _printable_ characters as per the spec.
Expand All @@ -549,27 +549,27 @@ private Task EnableShellIntegrationAsync(CancellationToken cancellationToken)
$Result += ""`a""
# Command finished exit code
# OSC 633 ; D [; <ExitCode>] ST
$Result += ""`e]633;D;$FakeCode`a""
$Result += ""$([char]0x1b)]633;D;$FakeCode`a""
}
}
# Prompt started
# OSC 633 ; A ST
$Result += ""`e]633;A`a""
$Result += ""$([char]0x1b)]633;A`a""
# Current working directory
# OSC 633 ; <Property>=<Value> ST
$Result += if($pwd.Provider.Name -eq 'FileSystem'){""`e]633;P;Cwd=$($pwd.ProviderPath)`a""}
$Result += if($pwd.Provider.Name -eq 'FileSystem'){""$([char]0x1b)]633;P;Cwd=$($pwd.ProviderPath)`a""}
# Before running the original prompt, put $? back to what it was:
if ($FakeCode -ne 0) { Write-Error ""failure"" -ea ignore }
# Run the original prompt
$Result += $Global:__VSCodeOriginalPrompt.Invoke()
# Write command started
$Result += ""`e]633;B`a""
$Result += ""$([char]0x1b)]633;B`a""
$Global:__LastHistoryId = $LastHistoryEntry.Id
return $Result
}

# Set IsWindows property
Write-Host -NoNewLine ""`e]633;P;IsWindows=$($IsWindows)`a""
Write-Host -NoNewLine ""$([char]0x1b)]633;P;IsWindows=$($IsWindows)`a""

# Set always on key handlers which map to default VS Code keybindings
function Set-MappedKeyHandler {
Expand Down