diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index 0cf957cda0e56..ef363fcf04694 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -654,11 +654,6 @@ export interface ITerminalInstance { */ userHome: string | undefined; - /** - * Shows the environment information hover if the widget exists. - */ - showEnvironmentInfoHover(): void; - /** * Registers and returns a marker */ diff --git a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts index fe07cbe1b793d..25b6a16a8cdad 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts @@ -1307,20 +1307,21 @@ export function registerTerminalActions() { accessor.get(ITerminalService).activeInstance?.relaunch(); } }); - registerAction2(class extends Action2 { - constructor() { - super({ - id: TerminalCommandId.ShowEnvironmentInformation, - title: { value: localize('workbench.action.terminal.showEnvironmentInformation', "Show Environment Information"), original: 'Show Environment Information' }, - f1: true, - category, - precondition: TerminalContextKeys.processSupported - }); - } - run(accessor: ServicesAccessor) { - accessor.get(ITerminalService).activeInstance?.showEnvironmentInfoHover(); - } - }); + // TODO: Ensure this information is keyboard accessible + // registerAction2(class extends Action2 { + // constructor() { + // super({ + // id: TerminalCommandId.ShowEnvironmentInformation, + // title: { value: localize('workbench.action.terminal.showEnvironmentInformation', "Show Environment Information"), original: 'Show Environment Information' }, + // f1: true, + // category, + // precondition: TerminalContextKeys.processSupported + // }); + // } + // run(accessor: ServicesAccessor) { + // accessor.get(ITerminalService).activeInstance?.showEnvironmentInfoHover(); + // } + // }); registerAction2(class extends Action2 { constructor() { super({ diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 3fb73f164abab..811bdfdf195df 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -64,7 +64,6 @@ import { showRunRecentQuickPick } from 'vs/workbench/contrib/terminal/browser/te import { ITerminalStatusList, TerminalStatus, TerminalStatusList } from 'vs/workbench/contrib/terminal/browser/terminalStatusList'; import { TypeAheadAddon } from 'vs/workbench/contrib/terminal/browser/xterm/terminalTypeAheadAddon'; import { getTerminalResourcesFromDragEvent, getTerminalUri } from 'vs/workbench/contrib/terminal/browser/terminalUri'; -import { EnvironmentVariableInfoWidget } from 'vs/workbench/contrib/terminal/browser/widgets/environmentVariableInfoWidget'; import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/widgets/widgetManager'; import { ITerminalQuickFixAddon, TerminalQuickFixAddon } from 'vs/workbench/contrib/terminal/browser/xterm/quickFixAddon'; import { LineDataEventAddon } from 'vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon'; @@ -193,7 +192,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _icon: TerminalIcon | undefined; private _messageTitleDisposable: IDisposable | undefined; private _widgetManager: TerminalWidgetManager = new TerminalWidgetManager(); - private _environmentInfo: { widget: EnvironmentVariableInfoWidget; disposable: IDisposable } | undefined; private _dndObserver: IDisposable | undefined; private _lastLayoutDimensions: dom.Dimension | undefined; private _hasHadInput: boolean; @@ -1734,8 +1732,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { // Dispose the environment info widget if it exists this.statusList.remove(TerminalStatus.RelaunchNeeded); - this._environmentInfo?.disposable.dispose(); - this._environmentInfo = undefined; if (!reset) { // HACK: Force initialText to be non-falsy for reused terminals such that the @@ -2137,12 +2133,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { this._shellLaunchConfig.env = shellLaunchConfig.env; } - showEnvironmentInfoHover(): void { - if (this._environmentInfo) { - this._environmentInfo.widget.focus(); - } - } - private _onEnvironmentVariableInfoChanged(info: IEnvironmentVariableInfo): void { if (info.requiresAction) { this.xterm?.raw.textarea?.setAttribute('aria-label', nls.localize('terminalStaleTextBoxAriaLabel', "Terminal {0} environment is stale, run the 'Show Environment Information' command for more information", this._instanceId)); @@ -2152,15 +2142,21 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _refreshEnvironmentVariableInfoWidgetState(info?: IEnvironmentVariableInfo): void { // Check if the widget should not exist - if ( - !info || - this._configHelper.config.environmentChangesIndicator === 'off' || - this._configHelper.config.environmentChangesIndicator === 'warnonly' && !info.requiresAction || - this._configHelper.config.environmentChangesIndicator === 'on' && !info.requiresAction - ) { + // if ( + // !info || + // this._configHelper.config.environmentChangesIndicator === 'off' || + // this._configHelper.config.environmentChangesIndicator === 'warnonly' && !info.requiresAction || + // this._configHelper.config.environmentChangesIndicator === 'on' && !info.requiresAction + // ) { + // this.statusList.remove(TerminalStatus.RelaunchNeeded); + // this._environmentInfo?.disposable.dispose(); + // this._environmentInfo = undefined; + // return; + // } + + if (!info) { this.statusList.remove(TerminalStatus.RelaunchNeeded); - this._environmentInfo?.disposable.dispose(); - this._environmentInfo = undefined; + this.statusList.remove(TerminalStatus.EnvironmentVariableInfoChangesActive); return; } @@ -2179,10 +2175,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { return; } - // (Re-)create the widget - this._environmentInfo?.disposable.dispose(); - const widget = this._scopedInstantiationService.createInstance(EnvironmentVariableInfoWidget, info); - const disposable = this._widgetManager.attachWidget(widget); + // Re-create statuses + // TODO: Move these into the info interface if (info.requiresAction) { this.statusList.add({ id: TerminalStatus.RelaunchNeeded, @@ -2191,10 +2185,17 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { tooltip: info.getInfo(), hoverActions: info.getActions ? info.getActions() : undefined }); + } else { + this.statusList.add({ + id: TerminalStatus.EnvironmentVariableInfoChangesActive, + severity: Severity.Info, + tooltip: info.getInfo(), + hoverActions: info.getActions ? info.getActions() : undefined + }); } - if (disposable) { - this._environmentInfo = { widget, disposable }; - } + // if (disposable) { + // this._environmentInfo = { widget, disposable }; + // } } async toggleEscapeSequenceLogging(): Promise { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts b/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts index 9f8599d214efa..7ebaefc714c5c 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts @@ -22,6 +22,7 @@ export const enum TerminalStatus { Bell = 'bell', Disconnected = 'disconnected', RelaunchNeeded = 'relaunch-needed', + EnvironmentVariableInfoChangesActive = 'env-var-info-changes-active', ShellIntegrationAttentionNeeded = 'shell-integration-attention-needed' } diff --git a/src/vs/workbench/contrib/terminal/browser/widgets/environmentVariableInfoWidget.ts b/src/vs/workbench/contrib/terminal/browser/widgets/environmentVariableInfoWidget.ts deleted file mode 100644 index 6061fe749a516..0000000000000 --- a/src/vs/workbench/contrib/terminal/browser/widgets/environmentVariableInfoWidget.ts +++ /dev/null @@ -1,92 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Widget } from 'vs/base/browser/ui/widget'; -import { IEnvironmentVariableInfo } from 'vs/workbench/contrib/terminal/common/environmentVariable'; -import { MarkdownString } from 'vs/base/common/htmlContent'; -import { ITerminalWidget } from 'vs/workbench/contrib/terminal/browser/widgets/widgets'; -import { RunOnceScheduler } from 'vs/base/common/async'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import * as dom from 'vs/base/browser/dom'; -import { IDisposable } from 'vs/base/common/lifecycle'; -import { IHoverService, IHoverOptions } from 'vs/workbench/services/hover/browser/hover'; -import { ThemeIcon } from 'vs/base/common/themables'; - -export class EnvironmentVariableInfoWidget extends Widget implements ITerminalWidget { - readonly id = 'env-var-info'; - - private _domNode: HTMLElement | undefined; - private _container: HTMLElement | undefined; - private _mouseMoveListener: IDisposable | undefined; - private _hoverOptions: IHoverOptions | undefined; - - get requiresAction() { return this._info.requiresAction; } - - constructor( - private _info: IEnvironmentVariableInfo, - @IConfigurationService private readonly _configurationService: IConfigurationService, - @IHoverService private readonly _hoverService: IHoverService - ) { - super(); - } - - attach(container: HTMLElement): void { - this._container = container; - this._domNode = document.createElement('div'); - this._domNode.classList.add('terminal-env-var-info', ...ThemeIcon.asClassNameArray(this._info.getIcon())); - if (this.requiresAction) { - this._domNode.classList.add('requires-action'); - } - container.appendChild(this._domNode); - - const scheduler: RunOnceScheduler = new RunOnceScheduler(() => this._showHover(), this._configurationService.getValue('workbench.hover.delay')); - this._register(scheduler); - const origin = { x: 0, y: 0 }; - - this.onmouseover(this._domNode, e => { - origin.x = e.browserEvent.pageX; - origin.y = e.browserEvent.pageY; - scheduler.schedule(); - - this._mouseMoveListener = dom.addDisposableListener(this._domNode!, dom.EventType.MOUSE_MOVE, e => { - // Reset the scheduler if the mouse moves too much - if (Math.abs(e.pageX - origin.x) > window.devicePixelRatio * 2 || Math.abs(e.pageY - origin.y) > window.devicePixelRatio * 2) { - origin.x = e.pageX; - origin.y = e.pageY; - scheduler.schedule(); - } - }); - }); - this.onmouseleave(this._domNode, () => { - scheduler.cancel(); - this._mouseMoveListener?.dispose(); - }); - } - - override dispose() { - super.dispose(); - this._domNode?.parentElement?.removeChild(this._domNode); - this._mouseMoveListener?.dispose(); - } - - focus() { - this._showHover(true); - } - - private _showHover(focus?: boolean) { - if (!this._domNode || !this._container) { - return; - } - if (!this._hoverOptions) { - const actions = this._info.getActions ? this._info.getActions() : undefined; - this._hoverOptions = { - target: this._domNode, - content: new MarkdownString(this._info.getInfo()), - actions - }; - } - this._hoverService.showHover(this._hoverOptions, focus); - } -} diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index 5381e1be66c3b..65c6450b42afc 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -569,7 +569,6 @@ export const enum TerminalCommandId { ToggleFindRegex = 'workbench.action.terminal.toggleFindRegex', ToggleFindWholeWord = 'workbench.action.terminal.toggleFindWholeWord', ToggleFindCaseSensitive = 'workbench.action.terminal.toggleFindCaseSensitive', - ShowEnvironmentInformation = 'workbench.action.terminal.showEnvironmentInformation', SearchWorkspace = 'workbench.action.terminal.searchWorkspace', AttachToSession = 'workbench.action.terminal.attachToSession', DetachSession = 'workbench.action.terminal.detachSession',