diff --git a/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts b/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts index 6aab13ed5a2..56b2820565d 100644 --- a/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts +++ b/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts @@ -13,6 +13,7 @@ import { ITerminalOutputMatcher } from '../terminal.js'; import { ICurrentPartialCommand, PartialTerminalCommand, TerminalCommand } from './commandDetection/terminalCommand.js'; import { PromptInputModel, type IPromptInputModel } from './commandDetection/promptInputModel.js'; import type { IBuffer, IDisposable, IMarker, Terminal } from '@xterm/headless'; +import { isString } from '../../../../base/common/types.js'; interface ITerminalDimensions { cols: number; @@ -371,8 +372,8 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe this._nextCommandId = undefined; // Clear the pending ID } else if ( this._nextCommandId && - typeof this.currentCommand.command === 'string' && - typeof this._nextCommandId.command === 'string' && + isString(this.currentCommand.command) && + isString(this._nextCommandId.command) && this.currentCommand.command.trim() === this._nextCommandId.command.trim() ) { this._currentCommand.id = this._nextCommandId.commandId; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts index 2033131066a..35fe84b73dd 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts @@ -97,7 +97,6 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce private _dataFilter: SeamlessRelaunchDataFilter; private _processListeners?: IDisposable[]; private _isDisconnected: boolean = false; - private _hasLoggedSetNextCommandIdFallback = false; private _processTraits: IProcessReadyEvent | undefined; private _shellLaunchConfig?: IShellLaunchConfig; @@ -599,27 +598,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce if (!process) { return; } - try { - await process.setNextCommandId(commandLine, commandId); - } catch (error) { - if (!this._shouldIgnoreSetNextCommandIdError(error)) { - throw error; - } - } - } - - private _shouldIgnoreSetNextCommandIdError(error: unknown): boolean { - if (!(error instanceof Error) || !error.message) { - return false; - } - if (!error.message.includes('Method not found: setNextCommandId') && !error.message.includes('Method not found: $setNextCommandId')) { - return false; - } - if (!this._hasLoggedSetNextCommandIdFallback) { - this._hasLoggedSetNextCommandIdFallback = true; - this._logService.trace('setNextCommandId not supported by current terminal backend, falling back.'); - } - return true; + await process.setNextCommandId(commandLine, commandId); } private _resize(cols: number, rows: number) {