mirror of
https://github.com/Microsoft/vscode
synced 2024-10-05 19:02:54 +00:00
parent
ce7105088c
commit
6ddf63fd33
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import type { IPromptInputModel } from 'vs/platform/terminal/common/capabilities/commandDetection/promptInputModel';
|
||||
import type { IPromptInputModel, ISerializedPromptInputModel } from 'vs/platform/terminal/common/capabilities/commandDetection/promptInputModel';
|
||||
import { ICurrentPartialCommand } from 'vs/platform/terminal/common/capabilities/commandDetection/terminalCommand';
|
||||
import { ITerminalOutputMatch, ITerminalOutputMatcher } from 'vs/platform/terminal/common/terminal';
|
||||
import { ReplayEntry } from 'vs/platform/terminal/common/terminalProcess';
|
||||
|
@ -301,6 +301,7 @@ export interface IMarkProperties {
|
|||
export interface ISerializedCommandDetectionCapability {
|
||||
isWindowsPty: boolean;
|
||||
commands: ISerializedTerminalCommand[];
|
||||
promptInputModel: ISerializedPromptInputModel | undefined;
|
||||
}
|
||||
export interface IPtyHostProcessReplayEvent {
|
||||
events: ReplayEntry[];
|
||||
|
|
|
@ -49,6 +49,14 @@ export interface IPromptInputModelState {
|
|||
readonly ghostTextIndex: number;
|
||||
}
|
||||
|
||||
export interface ISerializedPromptInputModel {
|
||||
readonly modelState: IPromptInputModelState;
|
||||
readonly commandStartX: number;
|
||||
readonly lastPromptLine: string | undefined;
|
||||
readonly continuationPrompt: string | undefined;
|
||||
readonly lastUserInput: string;
|
||||
}
|
||||
|
||||
export class PromptInputModel extends Disposable implements IPromptInputModel {
|
||||
private _state: PromptInputState = PromptInputState.Unknown;
|
||||
|
||||
|
@ -142,6 +150,26 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
serialize(): ISerializedPromptInputModel {
|
||||
return {
|
||||
modelState: this._createStateObject(),
|
||||
commandStartX: this._commandStartX,
|
||||
lastPromptLine: this._lastPromptLine,
|
||||
continuationPrompt: this._continuationPrompt,
|
||||
lastUserInput: this._lastUserInput
|
||||
};
|
||||
}
|
||||
|
||||
deserialize(serialized: ISerializedPromptInputModel): void {
|
||||
this._value = serialized.modelState.value;
|
||||
this._cursorIndex = serialized.modelState.cursorIndex;
|
||||
this._ghostTextIndex = serialized.modelState.ghostTextIndex;
|
||||
this._commandStartX = serialized.commandStartX;
|
||||
this._lastPromptLine = serialized.lastPromptLine;
|
||||
this._continuationPrompt = serialized.continuationPrompt;
|
||||
this._lastUserInput = serialized.lastUserInput;
|
||||
}
|
||||
|
||||
private _handleCommandStart(command: { marker: IMarker }) {
|
||||
if (this._state === PromptInputState.Input) {
|
||||
return;
|
||||
|
|
|
@ -408,7 +408,8 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
|
|||
}
|
||||
return {
|
||||
isWindowsPty: this._ptyHeuristics.value instanceof WindowsPtyHeuristics,
|
||||
commands
|
||||
commands,
|
||||
promptInputModel: this._promptInputModel.serialize(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -443,6 +444,9 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
|
|||
this._logService.debug('CommandDetectionCapability#onCommandFinished', newCommand);
|
||||
this._onCommandFinished.fire(newCommand);
|
||||
}
|
||||
if (serialized.promptInputModel) {
|
||||
this._promptInputModel.deserialize(serialized.promptInputModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,8 @@ export class TerminalRecorder {
|
|||
// No command restoration is needed when relaunching terminals
|
||||
commands: {
|
||||
isWindowsPty: false,
|
||||
commands: []
|
||||
commands: [],
|
||||
promptInputModel: undefined,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -577,7 +577,8 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
|
|||
if (!this._terminal || !this.capabilities.has(TerminalCapability.CommandDetection)) {
|
||||
return {
|
||||
isWindowsPty: false,
|
||||
commands: []
|
||||
commands: [],
|
||||
promptInputModel: undefined,
|
||||
};
|
||||
}
|
||||
const result = this._createOrGetCommandDetection(this._terminal).serialize();
|
||||
|
|
Loading…
Reference in a new issue