未验证 提交 83519f2c 编写于 作者: M meganrogge

move consts to terminal.ts, investigate why prompt data is missing

上级 90e1ba1b
......@@ -850,3 +850,18 @@ export const enum LinuxDistro {
Fedora = 2,
Ubuntu = 3,
}
export enum ShellIntegrationInteraction {
PromptStart = 'PROMPT_START',
CommandStart = 'COMMAND_START',
CommandExecuted = 'COMMAND_EXECUTED',
CommandFinished = 'COMMAND_FINISHED'
}
export enum ShellIntegrationInfo {
RemoteHost = 'RemoteHost',
CurrentDir = 'CurrentDir',
}
export interface IShellChangeEvent { type: ShellIntegrationInfo | ShellIntegrationInteraction, value: string }
......@@ -5,6 +5,7 @@
import type { Terminal, IMarker, ITerminalAddon } from 'xterm';
import { ICommandTracker } from 'vs/workbench/contrib/terminal/common/terminal';
import { ShellIntegrationInfo, ShellIntegrationInteraction } from 'vs/workbench/contrib/terminal/browser/terminal';
/**
* The minimum size of the prompt in which to assume the line is a command.
*/
......@@ -24,16 +25,33 @@ export class CommandTrackerAddon implements ICommandTracker, ITerminalAddon {
private _selectionStart: IMarker | Boundary | null = null;
private _isDisposable: boolean = false;
private _terminal: Terminal | undefined;
private _exitCode: number | undefined;
private _cwd: string | undefined;
private _prompt: string | undefined;
activate(terminal: Terminal): void {
this._terminal = terminal;
terminal.onIntegratedShellChange(e => {
if (this._terminal && this._terminal.buffer.active.cursorX >= MINIMUM_PROMPT_LENGTH) {
if (e.type === 'COMMAND_FINISHED') {
//TODO check exit code?
if (e.type === ShellIntegrationInteraction.CommandFinished) {
this._exitCode = Number.parseInt(e.value);
this._terminal?.registerMarker(0);
this.clearMarker();
}
} else if (this._terminal) {
if (e.type === ShellIntegrationInfo.CurrentDir) {
this._cwd = e.value;
} else if (e.type === ShellIntegrationInfo.RemoteHost) {
console.log('remote host', e.value);
console.log('line is', this._terminal.buffer.active.getLine(this._terminal.buffer.active.baseY)?.translateToString());
} else if (e.type === ShellIntegrationInteraction.PromptStart) {
console.log('prompt');
this._prompt = this._terminal.buffer.active.getLine(0)?.translateToString();
console.log('line is', this._prompt);
} else if (e.type === ShellIntegrationInteraction.CommandStart) {
console.log('command start ');
this._prompt = this._terminal.buffer.active.getLine(this._terminal.buffer.active.baseY)?.translateToString();
}
}
});
}
......
......@@ -15,7 +15,7 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { TerminalLocation, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
import { ICommandTracker, ITerminalFont, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { isSafari } from 'vs/base/browser/browser';
import { IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal';
import { IXtermTerminal, ShellIntegrationInfo, ShellIntegrationInteraction } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ILogService } from 'vs/platform/log/common/log';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { TerminalStorageKeys } from 'vs/workbench/contrib/terminal/common/terminalStorageKeys';
......@@ -511,17 +511,3 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal {
}
}
}
export enum ShellIntegrationInteraction {
PromptStart = 'PROMPT_START',
CommandStart = 'COMMAND_START',
CommandExecuted = 'COMMAND_EXECUTED',
CommandFinished = 'COMMAND_FINISHED'
}
export enum ShellIntegrationInfo {
RemoteHost = 'RemoteHost',
CurrentDir = 'CurrentDir',
}
export interface IShellChangeEvent { type: ShellIntegrationInfo | ShellIntegrationInteraction, value: string }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册