Skip to content

Commit 68aab69

Browse files
committed
Revert "feat(terminal): replace pWaitFor with event-based shell integration wait; add cmd.exe fast-path"
This reverts commit 40e17b1.
1 parent 8b40e88 commit 68aab69

2 files changed

Lines changed: 5 additions & 26 deletions

File tree

src/__mocks__/vscode.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export const window = {
8181
sendText: () => {},
8282
}),
8383
onDidCloseTerminal: () => mockDisposable,
84-
onDidChangeTerminalShellIntegration: () => mockDisposable,
8584
createTextEditorDecorationType: () => ({ dispose: () => {} }),
8685
}
8786

src/integrations/terminal/Terminal.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { existsSync } from "fs"
22
import * as path from "path"
33

44
import * as vscode from "vscode"
5+
import pWaitFor from "p-wait-for"
56

67
import type { RooTerminalCallbacks, RooTerminalProcessResultPromise } from "./types"
78
import { BaseTerminal } from "./BaseTerminal"
@@ -102,30 +103,6 @@ export class Terminal extends BaseTerminal {
102103
reject(error)
103104
})
104105

105-
// Wait for shell integration before executing the command. Use the
106-
// event-based API rather than polling so we react immediately when
107-
// VS Code's injector fires instead of burning CPU on a tight loop.
108-
const waitForShellIntegration = (): Promise<void> => {
109-
if (this.terminal.shellIntegration !== undefined) {
110-
return Promise.resolve()
111-
}
112-
113-
return new Promise<void>((res, rej) => {
114-
const timeoutId = setTimeout(() => {
115-
disposable.dispose()
116-
rej(new Error("timeout"))
117-
}, Terminal.getShellIntegrationTimeout())
118-
119-
const disposable = vscode.window.onDidChangeTerminalShellIntegration(({ terminal }) => {
120-
if (terminal === this.terminal) {
121-
clearTimeout(timeoutId)
122-
disposable.dispose()
123-
res()
124-
}
125-
})
126-
})
127-
}
128-
129106
if (Terminal.isActiveShellCmdExe()) {
130107
// Keep this defensive fallback for callers that invoke Terminal.runCommand()
131108
// directly instead of routing through executeCommandInTerminal().
@@ -138,7 +115,10 @@ export class Terminal extends BaseTerminal {
138115
commandSubmitted: false,
139116
})
140117
} else {
141-
waitForShellIntegration()
118+
// Wait for shell integration before executing the command
119+
pWaitFor(() => this.terminal.shellIntegration !== undefined, {
120+
timeout: Terminal.getShellIntegrationTimeout(),
121+
})
142122
.then(() => {
143123
// Clean up temporary directory if shell integration is available, zsh did its job:
144124
ShellIntegrationManager.zshCleanupTmpDir(this.id)

0 commit comments

Comments
 (0)