未验证 提交 0e7fc5fa 编写于 作者: D Daniel Imms

Add icon to launch config

Part of #120241
上级 17ae3eea
......@@ -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 {
......
......@@ -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';
......@@ -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
......
......@@ -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 {
......
......@@ -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
......@@ -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; }
......
......@@ -896,7 +896,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) {
......
......@@ -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 {
......
......@@ -238,6 +238,7 @@ export interface ITerminalProfile {
isWorkspaceProfile?: boolean;
args?: string | string[] | undefined;
overrideName?: boolean;
icon?: string;
}
export const enum ProfileSource {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册