Skip to content

Commit

Permalink
Show env changes in tab, remove widget
Browse files Browse the repository at this point in the history
Part of #151160
Part of #177078
  • Loading branch information
Tyriar committed Mar 14, 2023
1 parent 384b03f commit f41c665
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 137 deletions.
5 changes: 0 additions & 5 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
29 changes: 15 additions & 14 deletions src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
51 changes: 26 additions & 25 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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;
}

Expand All @@ -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,
Expand All @@ -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<boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f41c665

Please sign in to comment.