Skip to content

Commit 14d89d8

Browse files
authored
restore terminal color, icon, and name on restart (microsoft#136454)
1 parent e31a18e commit 14d89d8

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/vs/platform/terminal/node/ptyService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ export class PtyService extends Disposable implements IPtyService {
142142
{
143143
...state.shellLaunchConfig,
144144
cwd: state.processDetails.cwd,
145+
color: state.processDetails.color,
146+
icon: state.processDetails.icon,
147+
name: state.processDetails.title,
145148
initialText: state.replayEvent.events[0].data + '\x1b[0m\n\n\r\x1b[1;48;5;252;38;5;234m ' + restoreMessage + ' \x1b[K\x1b[0m\n\r'
146149
},
147150
state.processDetails.cwd,
@@ -190,7 +193,7 @@ export class PtyService extends Disposable implements IPtyService {
190193
executableEnv,
191194
windowsEnableConpty
192195
};
193-
const persistentProcess = new PersistentTerminalProcess(id, process, workspaceId, workspaceName, shouldPersist, cols, rows, processLaunchOptions, unicodeVersion, this._reconnectConstants, this._logService, isReviving ? shellLaunchConfig.initialText : undefined, shellLaunchConfig.icon, shellLaunchConfig.color, shellLaunchConfig.fixedDimensions);
196+
const persistentProcess = new PersistentTerminalProcess(id, process, workspaceId, workspaceName, shouldPersist, cols, rows, processLaunchOptions, unicodeVersion, this._reconnectConstants, this._logService, isReviving ? shellLaunchConfig.initialText : undefined, shellLaunchConfig.icon, shellLaunchConfig.color, shellLaunchConfig.name, shellLaunchConfig.fixedDimensions);
194197
process.onDidChangeProperty(property => this._onDidChangeProperty.fire({ id, property }));
195198
process.onProcessExit(event => {
196199
persistentProcess.dispose();
@@ -461,9 +464,13 @@ export class PersistentTerminalProcess extends Disposable {
461464
reviveBuffer: string | undefined,
462465
private _icon?: TerminalIcon,
463466
private _color?: string,
467+
name?: string,
464468
fixedDimensions?: IFixedTerminalDimensions
465469
) {
466470
super();
471+
if (name) {
472+
this.setTitle(name, TitleEventSource.Api);
473+
}
467474
this._logService.trace('persistentTerminalProcess#ctor', _persistentProcessId, arguments);
468475
this._wasRevived = reviveBuffer !== undefined;
469476
this._serializer = new XtermSerializer(

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
136136
private _containerReadyBarrier: AutoOpenBarrier;
137137
private _attachBarrier: AutoOpenBarrier;
138138

139+
private _icon: TerminalIcon | undefined;
140+
139141
private _messageTitleDisposable: IDisposable | undefined;
140142

141143
private _widgetManager: TerminalWidgetManager = this._instantiationService.createInstance(TerminalWidgetManager);
@@ -315,6 +317,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
315317

316318
this._fixedRows = _shellLaunchConfig.attachPersistentProcess?.fixedDimensions?.rows;
317319
this._fixedCols = _shellLaunchConfig.attachPersistentProcess?.fixedDimensions?.cols;
320+
this._icon = _shellLaunchConfig.attachPersistentProcess?.icon || _shellLaunchConfig.icon;
318321

319322
// the resource is already set when it's been moved from another window
320323
this._resource = resource || getTerminalUri(this._workspaceContextService.getWorkspace().id, this.instanceId, this.title);
@@ -409,11 +412,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
409412
}
410413

411414
private _getIcon(): TerminalIcon | undefined {
412-
const icon = this._shellLaunchConfig.icon || this._shellLaunchConfig.attachPersistentProcess?.icon;
413-
if (!icon) {
414-
return this._processManager.processState >= ProcessState.Launching ? Codicon.terminal : undefined;
415+
if (!this._icon) {
416+
this._icon = this._processManager.processState >= ProcessState.Launching ? Codicon.terminal : undefined;
415417
}
416-
return icon;
418+
return this._icon;
417419
}
418420

419421
private _getColor(): string | undefined {
@@ -1832,7 +1834,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
18321834
matchOnDescription: true
18331835
});
18341836
if (result && result.description) {
1835-
this.shellLaunchConfig.icon = iconRegistry.get(result.description);
1837+
this._icon = iconRegistry.get(result.description);
18361838
this._onIconChanged.fire(this);
18371839
}
18381840
}

0 commit comments

Comments
 (0)