Skip to content

Commit

Permalink
restore terminal color, icon, and name on restart (#136454)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge authored Nov 4, 2021
1 parent e31a18e commit 14d89d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/vs/platform/terminal/node/ptyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export class PtyService extends Disposable implements IPtyService {
{
...state.shellLaunchConfig,
cwd: state.processDetails.cwd,
color: state.processDetails.color,
icon: state.processDetails.icon,
name: state.processDetails.title,
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'
},
state.processDetails.cwd,
Expand Down Expand Up @@ -190,7 +193,7 @@ export class PtyService extends Disposable implements IPtyService {
executableEnv,
windowsEnableConpty
};
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);
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);
process.onDidChangeProperty(property => this._onDidChangeProperty.fire({ id, property }));
process.onProcessExit(event => {
persistentProcess.dispose();
Expand Down Expand Up @@ -461,9 +464,13 @@ export class PersistentTerminalProcess extends Disposable {
reviveBuffer: string | undefined,
private _icon?: TerminalIcon,
private _color?: string,
name?: string,
fixedDimensions?: IFixedTerminalDimensions
) {
super();
if (name) {
this.setTitle(name, TitleEventSource.Api);
}
this._logService.trace('persistentTerminalProcess#ctor', _persistentProcessId, arguments);
this._wasRevived = reviveBuffer !== undefined;
this._serializer = new XtermSerializer(
Expand Down
12 changes: 7 additions & 5 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _containerReadyBarrier: AutoOpenBarrier;
private _attachBarrier: AutoOpenBarrier;

private _icon: TerminalIcon | undefined;

private _messageTitleDisposable: IDisposable | undefined;

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

this._fixedRows = _shellLaunchConfig.attachPersistentProcess?.fixedDimensions?.rows;
this._fixedCols = _shellLaunchConfig.attachPersistentProcess?.fixedDimensions?.cols;
this._icon = _shellLaunchConfig.attachPersistentProcess?.icon || _shellLaunchConfig.icon;

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

private _getIcon(): TerminalIcon | undefined {
const icon = this._shellLaunchConfig.icon || this._shellLaunchConfig.attachPersistentProcess?.icon;
if (!icon) {
return this._processManager.processState >= ProcessState.Launching ? Codicon.terminal : undefined;
if (!this._icon) {
this._icon = this._processManager.processState >= ProcessState.Launching ? Codicon.terminal : undefined;
}
return icon;
return this._icon;
}

private _getColor(): string | undefined {
Expand Down Expand Up @@ -1832,7 +1834,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
matchOnDescription: true
});
if (result && result.description) {
this.shellLaunchConfig.icon = iconRegistry.get(result.description);
this._icon = iconRegistry.get(result.description);
this._onIconChanged.fire(this);
}
}
Expand Down

0 comments on commit 14d89d8

Please sign in to comment.