This commit is contained in:
Megan Rogge
2025-11-03 15:53:46 -05:00
committed by GitHub
parent 53cb6faa77
commit b8b8231b67
2 changed files with 4 additions and 24 deletions

View File

@@ -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;

View File

@@ -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) {