diff --git a/src/extension/chatSessions/vscode-node/copilotCLITerminalIntegration.ts b/src/extension/chatSessions/vscode-node/copilotCLITerminalIntegration.ts index 4817b3a7ed..bd909d865d 100644 --- a/src/extension/chatSessions/vscode-node/copilotCLITerminalIntegration.ts +++ b/src/extension/chatSessions/vscode-node/copilotCLITerminalIntegration.ts @@ -161,8 +161,8 @@ ELECTRON_RUN_AS_NODE=1 "${process.execPath}" "${path.join(storageLocation, COPIL private async sendCommandToTerminal(terminal: Terminal, command: string, waitForPythonActivation: boolean) { // Wait for shell integration to be available const shellIntegrationTimeout = 3000; - let shellIntegrationAvailable = false; - const integrationPromise = new Promise((resolve) => { + let shellIntegrationAvailable = terminal.shellIntegration ? true : false; + const integrationPromise = shellIntegrationAvailable ? Promise.resolve() : new Promise((resolve) => { const disposable = this._register(this.terminalService.onDidChangeTerminalShellIntegration(e => { if (e.terminal === terminal && e.shellIntegration) { shellIntegrationAvailable = true; @@ -185,7 +185,7 @@ ELECTRON_RUN_AS_NODE=1 "${process.execPath}" "${path.join(storageLocation, COPIL await new Promise(resolve => this._register(disposableTimeout(resolve, 500))); // Wait a bit to ensure the terminal is ready } - if (shellIntegrationAvailable && terminal.shellIntegration) { + if (terminal.shellIntegration) { terminal.shellIntegration.executeCommand(command); } else { terminal.sendText(command);