diff --git a/src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts b/src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts index 328f5f941ef82..31fb7a42da575 100644 --- a/src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts +++ b/src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts @@ -251,6 +251,12 @@ export class PromptInputModel extends Disposable implements IPromptInputModel { } const event = this._createStateObject(); + this._logService.trace(`PromptInputModel#_handleCommandExecuted: the value is::: "${this._value}"`); + this._logService.trace(`PromptInputModel#_handleCommandExecuted: we going to clear after this`); + // Clear value after creating the state object, since the command has been + // executed and is no longer editable prompt input + this._value = ''; + if (this._lastUserInput === '\u0003') { this._lastUserInput = ''; this._onDidInterrupt.fire(event); diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index ce934e637ac01..ff1b20f96ebca 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -985,15 +985,19 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { store.add(this.capabilities.onDidAddCommandDetectionCapability(e => { commandDetection = e; if (commandDetection.promptInputModel.state === PromptInputState.Input) { + this._logService.trace('runCommand: Command detection became available with prompt input, proceeding to run command'); r(); } else { store.add(commandDetection.promptInputModel.onDidStartInput(() => { + this._logService.trace('runCommand: Command detection prompt input started, proceeding to run command'); r(); })); } })); }), - timeout(timeoutMs) + timeout(timeoutMs).then(() => { + this._logService.trace(`runCommand: Timed out waiting for command detection prompt input after ${timeoutMs}ms, proceeding to run command`); + }) ]); store.dispose(); } @@ -1005,9 +1009,16 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { await this._processManager.setNextCommandId(commandLine, commandId); } + // TODO: Friday) + // - Figure out which of the component is leading to \x03 + // Determine whether to send ETX (ctrl+c) before running the command. Only do this when the // command will be executed immediately or when command detection shows the prompt contains text. if (shouldExecute && (!commandDetection || commandDetection.promptInputModel.value.length > 0)) { + this._logService.trace(`runCommand: Sending ^C before running command: ${commandLine}`); + this._logService.trace(`runCommand: The value of shouldExecute is: ${shouldExecute}`); + this._logService.trace(`runCommand: The value of command detection and prompt input model value is: ${commandDetection ? commandDetection.promptInputModel.value : 'N/A'}`); + await this.sendText('\x03', false); // Wait a little before running the command to avoid the sequences being echoed while the ^C // is being evaluated