From cddd795497bbc913a2811d6b0414a2e1dc0b1525 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 26 Jun 2025 12:04:57 -0700 Subject: [PATCH] Fire onCommandFinished even when the command is invalid Fixes #252489 --- .../common/capabilities/commandDetectionCapability.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts b/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts index a68f0487ebe05..70d698873f82c 100644 --- a/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts +++ b/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts @@ -391,10 +391,11 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe if (newCommand) { this._commands.push(newCommand); this._onBeforeCommandFinished.fire(newCommand); - if (!this._currentCommand.isInvalid) { - this._logService.debug('CommandDetectionCapability#onCommandFinished', newCommand); - this._onCommandFinished.fire(newCommand); - } + // NOTE: onCommandFinished used to not fire if the command was invalid, but this causes + // problems especially with the associated execution event never firing in the extension + // API. See https://github.com/microsoft/vscode/issues/252489 + this._logService.debug('CommandDetectionCapability#onCommandFinished', newCommand); + this._onCommandFinished.fire(newCommand); } this._currentCommand = new PartialTerminalCommand(this._terminal); this._handleCommandStartOptions = undefined;