diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index cd7e70c401006..51383a0e6aafe 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -378,9 +378,9 @@ export interface IShellLaunchConfig { name?: string; /** - * An string to follow the name of the terminal with, indicating a special kind of terminal + * A string to follow the name of the terminal with, indicating the type of terminal */ - description?: string; + type?: 'Task' | 'Local'; /** * The shell executable (bash, cmd, etc.). diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index 50ceec6859c9d..52905aed7be49 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -1035,7 +1035,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem { let isShellCommand = task.command.runtime === RuntimeType.Shell; let needsFolderQualification = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE; let terminalName = this.createTerminalName(task); - const description = nls.localize('TerminalTaskSystem.terminalDescription', 'Task'); + const type = 'Task'; let originalCommand = task.command.name; if (isShellCommand) { let os: Platform.OperatingSystem; @@ -1052,7 +1052,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem { }); shellLaunchConfig = { name: terminalName, - description, + type, executable: defaultProfile.path, args: defaultProfile.args, icon: defaultProfile.icon, @@ -1147,7 +1147,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem { // When we have a process task there is no need to quote arguments. So we go ahead and take the string value. shellLaunchConfig = { name: terminalName, - description, + type, executable: executable, args: args.map(a => Types.isString(a) ? a : a.value), waitOnExit diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts index 026993861147e..70e74e8e9209c 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts @@ -226,7 +226,7 @@ export class TerminalEditorInput extends EditorInput { } public override getDescription(): string | undefined { - return this._terminalInstance?.description || this._terminalInstance?.shellLaunchConfig.description; + return this._terminalInstance?.description || this._terminalInstance?.shellLaunchConfig.type; } public override toUntyped(): IUntypedEditorInput { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index 23e9e7d6cb500..44ad0a48a4dcd 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -167,7 +167,7 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor if (resource) { await this._editorService.openEditor({ resource, - description: instance.description || instance.shellLaunchConfig.description, + description: instance.description || instance.shellLaunchConfig.type, options: { pinned: true, diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index bdda95f59df83..a4a142a6fe833 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -138,15 +138,16 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private static _lastKnownGridDimensions: IGridDimensions | undefined; private static _instanceIdCounter = 1; - xterm?: XtermTerminal; - readonly capabilities = new TerminalCapabilityStoreMultiplexer(); + private readonly _processManager: ITerminalProcessManager; + private readonly _resource: URI; + // Enables disposal of the xterm onKey + // event when the CwdDetection capability + // is added + private _xtermOnKey: IDisposable | undefined; private _xtermReadyPromise: Promise; private _xtermTypeAheadAddon: TypeAheadAddon | undefined; - - private readonly _processManager: ITerminalProcessManager; private _pressAnyKeyToCloseListener: IDisposable | undefined; - private _instanceId: number; private _latestXtermWriteData: number = 0; private _latestXtermParseData: number = 0; @@ -178,33 +179,16 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _initialDataEvents: string[] | undefined = []; private _containerReadyBarrier: AutoOpenBarrier; private _attachBarrier: AutoOpenBarrier; - private _icon: TerminalIcon | undefined; - private _messageTitleDisposable: IDisposable | undefined; - private _widgetManager: TerminalWidgetManager = this._instantiationService.createInstance(TerminalWidgetManager); private _linkManager: TerminalLinkManager | undefined; private _environmentInfo: { widget: EnvironmentVariableInfoWidget, disposable: IDisposable } | undefined; private _navigationModeAddon: INavigationMode & ITerminalAddon | undefined; private _dndObserver: IDisposable | undefined; - - private readonly _resource: URI; - private _terminalLinkQuickpick: TerminalLinkQuickpick | undefined; - private _lastLayoutDimensions: dom.Dimension | undefined; - private _hasHadInput: boolean; - - // Enables disposal of the xterm onKey - // event when the CwdDetection capability - // is added - private _xtermOnKey: IDisposable | undefined; - - readonly statusList: ITerminalStatusList; - disableLayout: boolean = false; - private _description?: string; private _processName: string = ''; private _sequence?: string; @@ -215,6 +199,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _hasScrollBar?: boolean; private _target?: TerminalLocation | undefined; + readonly capabilities = new TerminalCapabilityStoreMultiplexer(); + readonly statusList: ITerminalStatusList; + + xterm?: XtermTerminal; + disableLayout: boolean = false; + get target(): TerminalLocation | undefined { return this._target; } set target(value: TerminalLocation | undefined) { if (this.xterm) { @@ -262,7 +252,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { get areLinksReady(): boolean { return this._areLinksReady; } get initialDataEvents(): string[] | undefined { return this._initialDataEvents; } get exitCode(): number | undefined { return this._exitCode; } - get hadFocusOnExit(): boolean { return this._hadFocusOnExit; } get isTitleSetByProcess(): boolean { return !!this._messageTitleDisposable; } get shellLaunchConfig(): IShellLaunchConfig { return this._shellLaunchConfig; } @@ -276,20 +265,30 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { get titleSource(): TitleEventSource { return this._titleSource; } get icon(): TerminalIcon | undefined { return this._getIcon(); } get color(): string | undefined { return this._getColor(); } - get processName(): string { return this._processName; } get sequence(): string | undefined { return this._sequence; } get staticTitle(): string | undefined { return this._staticTitle; } get workspaceFolder(): string | undefined { return this._workspaceFolder; } get cwd(): string | undefined { return this._cwd; } get initialCwd(): string | undefined { return this._initialCwd; } - get description(): string | undefined { return this._description || this.shellLaunchConfig.description; } + get description(): string | undefined { + if (this._description) { + return this._description; + } else if (this._shellLaunchConfig.type) { + if (this._shellLaunchConfig.type === 'Task') { + return nls.localize('terminalTypeTask', "Task"); + } else { + return nls.localize('terminalTypeLocal', "Local"); + } + } + return undefined; + } get userHome(): string | undefined { return this._userHome; } + // The onExit event is special in that it fires and is disposed after the terminal instance // itself is disposed private readonly _onExit = new Emitter(); readonly onExit = this._onExit.event; - private readonly _onDisposed = this._register(new Emitter()); readonly onDisposed = this._onDisposed.event; private readonly _onProcessIdReady = this._register(new Emitter()); @@ -2273,10 +2272,10 @@ export class TerminalLabelComputer extends Disposable { cwd: this._instance.cwd || this._instance.initialCwd || '', cwdFolder: '', workspaceFolder: this._instance.workspaceFolder, - local: this._instance.shellLaunchConfig.description === 'Local' ? 'Local' : undefined, + local: this._instance.shellLaunchConfig.type === 'Local' ? this._instance.shellLaunchConfig.type : undefined, process: this._instance.processName, sequence: this._instance.sequence, - task: this._instance.shellLaunchConfig.description === 'Task' ? 'Task' : undefined, + task: this._instance.shellLaunchConfig.type === 'Task' ? this._instance.shellLaunchConfig.type : undefined, fixedDimensions: this._instance.fixedCols ? (this._instance.fixedRows ? `\u2194${this._instance.fixedCols} \u2195${this._instance.fixedRows}` : `\u2194${this._instance.fixedCols}`) : (this._instance.fixedRows ? `\u2195${this._instance.fixedRows}` : ''), diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index 9a2186bec36ab..e8e5107789ecd 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -1074,10 +1074,10 @@ export class TerminalService implements ITerminalService { if (typeof shellLaunchConfig.cwd !== 'string' && shellLaunchConfig.cwd?.scheme === Schemas.file) { if (VirtualWorkspaceContext.getValue(this._contextKeyService)) { shellLaunchConfig.initialText = formatMessageForTerminal(nls.localize('localTerminalVirtualWorkspace', "⚠ : This shell is open to a {0}local{1} folder, NOT to the virtual folder", '\x1b[3m', '\x1b[23m'), true); - shellLaunchConfig.description = nls.localize('localTerminalDescription', "Local"); + shellLaunchConfig.type = 'Local'; } else if (this._remoteAgentService.getConnection()) { shellLaunchConfig.initialText = formatMessageForTerminal(nls.localize('localTerminalRemote', "⚠ : This shell is running on your {0}local{1} machine, NOT on the connected remote machine", '\x1b[3m', '\x1b[23m'), true); - shellLaunchConfig.description = nls.localize('localTerminalDescription', "Local"); + shellLaunchConfig.type = 'Local'; } } } diff --git a/src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts b/src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts index 8ee4a907138da..fc1f3eaef5863 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts @@ -233,7 +233,7 @@ suite('Workbench - TerminalInstance', () => { test('should resolve local', () => { configurationService = new TestConfigurationService({ terminal: { integrated: { tabs: { separator: ' - ', title: '${local}', description: '${local}' } } } }); configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!, null!, null!); - terminalLabelComputer = new TerminalLabelComputer(configHelper, createInstance({ capabilities, processName: 'zsh', shellLaunchConfig: { description: 'Local' } }), mockContextService); + terminalLabelComputer = new TerminalLabelComputer(configHelper, createInstance({ capabilities, processName: 'zsh', shellLaunchConfig: { type: 'Local' } }), mockContextService); terminalLabelComputer.refreshLabel(); strictEqual(terminalLabelComputer.title, 'Local'); strictEqual(terminalLabelComputer.description, 'Local'); @@ -257,7 +257,7 @@ suite('Workbench - TerminalInstance', () => { test('should resolve task', () => { configurationService = new TestConfigurationService({ terminal: { integrated: { tabs: { separator: ' ~ ', title: '${process}${separator}${task}', description: '${task}' } } } }); configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!, null!, null!); - terminalLabelComputer = new TerminalLabelComputer(configHelper, createInstance({ capabilities, processName: 'zsh', shellLaunchConfig: { description: 'Task' } }), mockContextService); + terminalLabelComputer = new TerminalLabelComputer(configHelper, createInstance({ capabilities, processName: 'zsh', shellLaunchConfig: { type: 'Task' } }), mockContextService); terminalLabelComputer.refreshLabel(); strictEqual(terminalLabelComputer.title, 'zsh ~ Task'); strictEqual(terminalLabelComputer.description, 'Task'); @@ -265,7 +265,7 @@ suite('Workbench - TerminalInstance', () => { test('should resolve separator', () => { configurationService = new TestConfigurationService({ terminal: { integrated: { tabs: { separator: ' ~ ', title: '${separator}', description: '${separator}' } } } }); configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!, null!, null!); - terminalLabelComputer = new TerminalLabelComputer(configHelper, createInstance({ capabilities, processName: 'zsh', shellLaunchConfig: { description: 'Task' } }), mockContextService); + terminalLabelComputer = new TerminalLabelComputer(configHelper, createInstance({ capabilities, processName: 'zsh', shellLaunchConfig: { type: 'Task' } }), mockContextService); terminalLabelComputer.refreshLabel(); strictEqual(terminalLabelComputer.title, 'zsh'); strictEqual(terminalLabelComputer.description, '');