diff --git a/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.ts b/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.ts index 025f5289f6a57..ed9ea1f02d179 100644 --- a/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.ts +++ b/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.ts @@ -9,6 +9,7 @@ import { ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal import { localize } from 'vs/nls'; import { ThemeIcon } from 'vs/platform/theme/common/themeService'; import { Codicon } from 'vs/base/common/codicons'; +import { IHoverAction } from 'vs/workbench/services/hover/browser/hover'; export class EnvironmentVariableInfoStale implements IEnvironmentVariableInfo { readonly requiresAction = true; @@ -59,7 +60,7 @@ export class EnvironmentVariableInfoStale implements IEnvironmentVariableInfo { return Codicon.warning; } - getActions(): { label: string, iconClass?: string, run: () => void, commandId: string }[] { + getActions(): IHoverAction[] { return [{ label: localize('relaunchTerminalLabel', "Relaunch terminal"), run: () => this._terminalService.getInstanceFromId(this._terminalId)?.relaunch(), diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index a30d80b74e26f..f66128be5cfa7 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1676,7 +1676,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { id: TerminalStatus.RelaunchNeeded, severity: Severity.Warning, icon: Codicon.warning, - tooltip: info.getInfo() + tooltip: info.getInfo(), + hoverActions: info.getActions ? info.getActions() : undefined }); } if (disposable) { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts b/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts index b7d9d7207250c..884c867e2f5ca 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts @@ -7,6 +7,7 @@ import { Codicon } from 'vs/base/common/codicons'; import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import Severity from 'vs/base/common/severity'; +import { IHoverAction } from 'vs/workbench/services/hover/browser/hover'; /** * The set of _internal_ terminal statuses, other components building on the terminal should put @@ -35,6 +36,10 @@ export interface ITerminalStatus { * What to show for this status in the terminal's hover. */ tooltip?: string | undefined; + /** + * Actions to expose on hover. + */ + hoverActions?: IHoverAction[]; } export interface ITerminalStatusList { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalTabsWidget.ts b/src/vs/workbench/contrib/terminal/browser/terminalTabsWidget.ts index 3949b66486afb..92621b417bc83 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalTabsWidget.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalTabsWidget.ts @@ -25,7 +25,7 @@ import { MarkdownString } from 'vs/base/common/htmlContent'; import { TerminalDecorationsProvider } from 'vs/workbench/contrib/terminal/browser/terminalDecorationsProvider'; import { DEFAULT_LABELS_CONTAINER, IResourceLabel, ResourceLabels } from 'vs/workbench/browser/labels'; import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations'; -import { IHoverService } from 'vs/workbench/services/hover/browser/hover'; +import { IHoverAction, IHoverService } from 'vs/workbench/services/hover/browser/hover'; import Severity from 'vs/base/common/severity'; import { DisposableStore } from 'vs/base/common/lifecycle'; @@ -141,14 +141,19 @@ class TerminalTabsRenderer implements ITreeRenderer('workbench.hover.delay'), - showHover: e => this._hoverService.showHover(e) + showHover: options => { + return this._hoverService.showHover({ + ...options, + actions: context.hoverActions + }); + } } }); @@ -164,7 +169,8 @@ class TerminalTabsRenderer implements ITreeRenderer `${e.tooltip || e.id}`); + template.context.hoverActions = []; + for (const status of statuses) { + title += `\n\n---\n\n${status.tooltip || status.id}`; + if (status.hoverActions) { + template.context.hoverActions.push(...status.hoverActions); + } } let label: string; @@ -265,5 +274,8 @@ interface ITerminalTabEntryTemplate { element: HTMLElement; label: IResourceLabel; actionBar: ActionBar; + context: { + hoverActions?: IHoverAction[]; + }; elementDispoables?: DisposableStore; } diff --git a/src/vs/workbench/contrib/terminal/common/environmentVariable.ts b/src/vs/workbench/contrib/terminal/common/environmentVariable.ts index b114ef38b2435..61e238e65c9e1 100644 --- a/src/vs/workbench/contrib/terminal/common/environmentVariable.ts +++ b/src/vs/workbench/contrib/terminal/common/environmentVariable.ts @@ -102,5 +102,10 @@ export interface IEnvironmentVariableInfo { readonly requiresAction: boolean; getInfo(): string; getIcon(): ThemeIcon; - getActions?(): { label: string, iconClass?: string, run: () => void, commandId: string }[]; + getActions?(): { + label: string; + commandId: string; + iconClass?: string; + run(target: HTMLElement): void; + }[]; }