Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore terminal color, icon, and name on restart #136454

Merged
merged 2 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
}
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