Try shell integration fix

This commit is contained in:
Saoud Rizwan
2024-09-25 00:25:37 -04:00
parent b347acf4f0
commit fb092289f2

View File

@@ -81,7 +81,7 @@ declare module "vscode" {
} }
// https://github.com/microsoft/vscode/blob/f0417069c62e20f3667506f4b7e53ca0004b4e3e/src/vscode-dts/vscode.d.ts#L10794 // https://github.com/microsoft/vscode/blob/f0417069c62e20f3667506f4b7e53ca0004b4e3e/src/vscode-dts/vscode.d.ts#L10794
interface Window { interface Window {
onDidEndTerminalShellExecution?: ( onDidStartTerminalShellExecution?: (
listener: (e: any) => any, listener: (e: any) => any,
thisArgs?: any, thisArgs?: any,
disposables?: vscode.Disposable[] disposables?: vscode.Disposable[]
@@ -95,17 +95,11 @@ export class TerminalManager {
private disposables: vscode.Disposable[] = [] private disposables: vscode.Disposable[] = []
constructor() { constructor() {
// Listening to this reduces the # of empty terminal outputs!
let disposable: vscode.Disposable | undefined let disposable: vscode.Disposable | undefined
try { try {
disposable = (vscode.window as vscode.Window).onDidEndTerminalShellExecution?.(async (e) => { disposable = (vscode.window as vscode.Window).onDidStartTerminalShellExecution?.(async (e) => {
// console.log(`Terminal shell execution ended. Command line:`, e.execution.commandLine.value) // Creating a read stream here results in a more consistent output. This is most obvious when running the `date` command.
const stream = e?.execution?.read() e?.execution?.read()
if (stream) {
for await (let _ of stream) {
// console.log(`from onDidEndTerminalShellExecution, read:`, data)
}
}
}) })
} catch (error) { } catch (error) {
// console.error("Error setting up onDidEndTerminalShellExecution", error) // console.error("Error setting up onDidEndTerminalShellExecution", error)
@@ -113,7 +107,6 @@ export class TerminalManager {
if (disposable) { if (disposable) {
this.disposables.push(disposable) this.disposables.push(disposable)
} }
// Oddly if we listen to `onDidStartTerminalShellExecution` or `onDidChangeTerminalShellIntegration` this hack doesn't work...
} }
runCommand(terminalInfo: TerminalInfo, command: string): TerminalProcessResultPromise { runCommand(terminalInfo: TerminalInfo, command: string): TerminalProcessResultPromise {