Skip to content

Commit 45d187b

Browse files
committed
Revert formatting changes in shell integration ps1
1 parent 5bb4cd1 commit 45d187b

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,22 @@ if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") {
1616
$Global:__VSCodeOriginalPrompt = $function:Prompt
1717

1818
$Global:__LastHistoryId = -1
19-
function Set-Serialized
20-
{
19+
function Set-Serialized {
2120
param ([string] $toSerialize)
2221
$toSerialize = $toSerialize.Replace("\", "\\").Replace("`n", "\x0a").Replace(";", "\x3b")
2322
return $toSerialize
2423
}
2524

26-
function Global:Prompt()
27-
{
25+
function Global:Prompt() {
2826
$FakeCode = [int]!$global:?
2927
$LastHistoryEntry = Get-History -Count 1
3028
# Skip finishing the command if the first command has not yet started
31-
if ($Global:__LastHistoryId -ne -1)
32-
{
33-
if ($LastHistoryEntry.Id -eq $Global:__LastHistoryId)
34-
{
29+
if ($Global:__LastHistoryId -ne -1) {
30+
if ($LastHistoryEntry.Id -eq $Global:__LastHistoryId) {
3531
# Don't provide a command line or exit code if there was no history entry (eg. ctrl+c, enter on no command)
3632
$Result = "$([char]0x1b)]633;E`a"
3733
$Result += "$([char]0x1b)]633;D`a"
38-
} else
39-
{
34+
} else {
4035
# Command finished command line
4136
# OSC 633 ; A ; <CommandLine?> ST
4237
$Result = "$([char]0x1b)]633;E;"
@@ -64,9 +59,9 @@ function Global:Prompt()
6459
# OSC 633 ; <Property>=<Value> ST
6560
$Result += if($pwd.Provider.Name -eq 'FileSystem'){"$([char]0x1b)]633;P;Cwd=$($pwd.ProviderPath)`a"}
6661
# Before running the original prompt, put $? back to what it was:
67-
if ($FakeCode -ne 0)
68-
{ Write-Error "failure" -ea ignore
69-
}
62+
if ($FakeCode -ne 0) {
63+
Write-Error "failure" -ea ignore
64+
}
7065
# Run the original prompt
7166
$Result += $Global:__VSCodeOriginalPrompt.Invoke()
7267
# Write command started
@@ -77,11 +72,9 @@ function Global:Prompt()
7772

7873
# Only send the command executed sequence when PSReadLine is loaded, if not shell integration should
7974
# still work thanks to the command line sequence
80-
if (Get-Module -Name PSReadLine)
81-
{
75+
if (Get-Module -Name PSReadLine) {
8276
$__VSCodeOriginalPSConsoleHostReadLine = $function:PSConsoleHostReadLine
83-
function Global:PSConsoleHostReadLine
84-
{
77+
function Global:PSConsoleHostReadLine {
8578
$tmp = $__VSCodeOriginalPSConsoleHostReadLine.Invoke()
8679
# Write command executed sequence directly to Console to avoid the new line from Write-Host
8780
[Console]::Write("$([char]0x1b)]633;C`a")
@@ -93,24 +86,24 @@ if (Get-Module -Name PSReadLine)
9386
[Console]::Write("$([char]0x1b)]633;P;IsWindows=$($IsWindows)`a")
9487

9588
# Set always on key handlers which map to default VS Code keybindings
96-
function Set-MappedKeyHandler
97-
{
89+
function Set-MappedKeyHandler {
9890
param ([string[]] $Chord, [string[]]$Sequence)
9991
$Handler = $(Get-PSReadLineKeyHandler -Chord $Chord | Select-Object -First 1)
100-
if ($Handler)
101-
{
92+
if ($Handler) {
10293
Set-PSReadLineKeyHandler -Chord $Sequence -Function $Handler.Function
10394
}
10495
}
105-
function Set-MappedKeyHandlers
106-
{
96+
97+
function Set-MappedKeyHandlers {
10798
Set-MappedKeyHandler -Chord Ctrl+Spacebar -Sequence 'F12,a'
10899
Set-MappedKeyHandler -Chord Alt+Spacebar -Sequence 'F12,b'
109100
Set-MappedKeyHandler -Chord Shift+Enter -Sequence 'F12,c'
110101
Set-MappedKeyHandler -Chord Shift+End -Sequence 'F12,d'
111102
}
112103

113104
Set-MappedKeyHandlers
105+
106+
# Send aliases to the terminal
114107
$result = $(Get-Alias | Select-Object Name, Definition)
115108
$resultStr = Out-String -InputObject $result
116109
$resultStr = Set-Serialized($resultStr)

0 commit comments

Comments
 (0)