Skip to content

Commit

Permalink
Add icon to launch config
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar authored and gjsjohnmurray committed Apr 8, 2021
1 parent 782830d commit ac79fed
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ export interface IShellLaunchConfig {
* Whether this terminal was created by an extension.
*/
isExtensionOwnedTerminal?: boolean;

/**
* The codicon ID to use for this terminal. If not specified it will use the default fallback
* icon.
*/
iconId?: string;
}

export interface IShellLaunchConfigDto {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Codicon } from 'vs/base/common/codicons';
import { Event } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IProcessEnvironment, Platform } from 'vs/base/common/platform';
Expand Down Expand Up @@ -244,6 +245,7 @@ export interface ITerminalInstance {
readonly rows: number;
readonly maxCols: number;
readonly maxRows: number;
readonly icon: Codicon;

/**
* The process ID of the shell process, this is undefined when there is no process associated
Expand Down
8 changes: 7 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,13 @@ export function registerTerminalActions() {
if (launchConfig) {
const workspaceShellAllowed = terminalService.configHelper.checkIsProcessLaunchSafe(undefined, launchConfig);
if (workspaceShellAllowed) {
const instance = terminalService.createTerminal({ executable: launchConfig.path, args: launchConfig.args, name: launchConfig.overrideName ? launchConfig.profileName : undefined });
// TODO: Share profile launch with that in terminalService
const instance = terminalService.createTerminal({
executable: launchConfig.path,
args: launchConfig.args,
iconId: launchConfig.icon,
name: launchConfig.overrideName ? launchConfig.profileName : undefined
});
terminalService.setActiveInstance(instance);
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { IProcessDataEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITe
import { IProductService } from 'vs/platform/product/common/productService';
import { formatMessageForTerminal } from 'vs/workbench/contrib/terminal/common/terminalStrings';
import { AutoOpenBarrier } from 'vs/base/common/async';
import { Codicon, iconRegistry } from 'vs/base/common/codicons';

// How long in milliseconds should an average frame take to render for a notification to appear
// which suggests the fallback DOM-based renderer
Expand Down Expand Up @@ -169,6 +170,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
public get commandTracker(): CommandTrackerAddon | undefined { return this._commandTrackerAddon; }
public get navigationMode(): INavigationMode | undefined { return this._navigationModeAddon; }
public get isDisconnected(): boolean { return this._processManager.isDisconnected; }
public get icon(): Codicon { return this.shellLaunchConfig.iconId ? (iconRegistry.get(this.shellLaunchConfig.iconId) || Codicon.terminal) : Codicon.terminal; }

private readonly _onExit = new Emitter<number | undefined>();
public get onExit(): Event<number | undefined> { return this._onExit.event; }
Expand Down
8 changes: 7 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,13 @@ export class TerminalService implements ITerminalService {
return;
}
if (type === 'createInstance') {
const launchConfig = { executable: value.profile.path, args: value.profile.args, name: value.profile.overrideName ? value.profile.profileName : undefined };
const launchConfig: IShellLaunchConfig = {
executable: value.profile.path,
args: value.profile.args,
iconId: value.profile.icon,
name: value.profile.overrideName ? value.profile.profileName : undefined
};

let instance;
const activeInstance = this.getActiveInstance();
if (keyMods?.alt && activeInstance) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export class TerminalTab extends Disposable implements ITerminalTab {
}

private _titleWithConnectionStatus(instance: ITerminalInstance): string {
return instance.isDisconnected ? localize('ptyDisconnected', "{0} (disconnected)", instance.title) : instance.title;
return instance.isDisconnected ? localize('ptyDisconnected', "{0} (disconnected)", instance.title) : `${instance.title} [${instance.icon.id}]`;
}

public setVisible(visible: boolean): void {
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export interface ITerminalProfile {
isWorkspaceProfile?: boolean;
args?: string | string[] | undefined;
overrideName?: boolean;
icon?: string;
}

export const enum ProfileSource {
Expand Down

0 comments on commit ac79fed

Please sign in to comment.