Skip to content

Commit

Permalink
Show env var info in single tab
Browse files Browse the repository at this point in the history
Fixes #171498
  • Loading branch information
Tyriar committed Jan 17, 2023
1 parent 1bf83c9 commit 992f45a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/terminal/browser/terminalTooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export function getShellIntegrationTooltip(instance: ITerminalInstance, markdown
}
let shellIntegrationString = '';
if (shellIntegrationCapabilities.length > 0) {
shellIntegrationString += `${markdown ? '\n\n---\n\n' : '\n\n'} ${localize('shellIntegration.enabled', "Shell integration activated")}`;
shellIntegrationString += `${markdown ? '\n\n---\n\n' : '\n\n'}${localize('shellIntegration.enabled', "Shell integration activated")}`;
} else {
if (instance.shellLaunchConfig.ignoreShellIntegration) {
shellIntegrationString += `${markdown ? '\n\n---\n\n' : '\n\n'} ${localize('launchFailed.exitCodeOnlyShellIntegration', "The terminal process failed to launch. Disabling shell integration with terminal.integrated.shellIntegration.enabled might help.")}`;
shellIntegrationString += `${markdown ? '\n\n---\n\n' : '\n\n'}${localize('launchFailed.exitCodeOnlyShellIntegration', "The terminal process failed to launch. Disabling shell integration with terminal.integrated.shellIntegration.enabled might help.")}`;
} else {
if (instance.usedShellIntegrationInjection) {
shellIntegrationString += `${markdown ? '\n\n---\n\n' : '\n\n'} ${localize('shellIntegration.activationFailed', "Shell integration failed to activate")}`;
shellIntegrationString += `${markdown ? '\n\n---\n\n' : '\n\n'}${localize('shellIntegration.activationFailed', "Shell integration failed to activate")}`;
}
}
}
Expand Down
39 changes: 24 additions & 15 deletions src/vs/workbench/contrib/terminal/browser/terminalView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/termin
import { getShellIntegrationTooltip } from 'vs/workbench/contrib/terminal/browser/terminalTooltip';
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
import { TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
import { Event } from 'vs/base/common/event';

export class TerminalViewPane extends ViewPane {
private _fontStyleElement: HTMLElement | undefined;
Expand Down Expand Up @@ -357,19 +358,25 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
super(action, { draggable: true }, keybindingService, notificationService, contextKeyService, themeService, contextMenuService);

// Register listeners to update the tab
this._register(this._terminalService.onDidChangeInstancePrimaryStatus(e => this.updateLabel(e)));
this._register(this._terminalGroupService.onDidChangeActiveInstance(() => this.updateLabel()));
this._register(this._terminalService.onDidChangeInstanceIcon(e => this.updateLabel(e.instance)));
this._register(this._terminalService.onDidChangeInstanceColor(e => this.updateLabel(e.instance)));
this._register(this._terminalService.onDidChangeInstanceTitle(e => {
if (e === this._terminalGroupService.activeInstance) {
this._action.tooltip = getSingleTabTooltip(e, this._terminalService.configHelper.config.tabs.separator);
this.updateLabel();
this._register(Event.debounce<ITerminalInstance | undefined, Set<ITerminalInstance>>(Event.any(
this._terminalService.onDidChangeInstancePrimaryStatus,
this._terminalGroupService.onDidChangeActiveInstance,
Event.map(this._terminalService.onDidChangeInstanceIcon, e => e.instance),
Event.map(this._terminalService.onDidChangeInstanceColor, e => e.instance),
this._terminalService.onDidChangeInstanceTitle,
this._terminalService.onDidChangeInstanceCapability,
), (last, e) => {
if (!last) {
last = new Set();
}
if (e) {
last.add(e);
}
return last;
})(merged => {
for (const e of merged) {
this.updateLabel(e);
}
}));
this._register(this._terminalService.onDidChangeInstanceCapability(e => {
this._action.tooltip = getSingleTabTooltip(e, this._terminalService.configHelper.config.tabs.separator);
this.updateLabel(e);
}));

// Clean up on dispose
Expand Down Expand Up @@ -465,6 +472,7 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
this._altCommand = `alt-command`;
label.classList.add(this._altCommand);
}
this._action.tooltip = getSingleTabTooltip(e, this._terminalService.configHelper.config.tabs.separator);
this.updateTooltip();
}
}
Expand Down Expand Up @@ -498,9 +506,10 @@ function getSingleTabTooltip(instance: ITerminalInstance | undefined, separator:
if (!instance) {
return '';
}
const shellIntegrationString = getShellIntegrationTooltip(instance, false);
const title = getSingleTabTitle(instance, separator);
return shellIntegrationString ? title + shellIntegrationString : title;
const parts: string[] = [];
parts.push(getSingleTabTitle(instance, separator) + getShellIntegrationTooltip(instance, false));
parts.push(instance.statusList.primary?.tooltip || '');
return parts.filter(e => e).join('\n\n');
}

function getSingleTabTitle(instance: ITerminalInstance | undefined, separator: string): string {
Expand Down

0 comments on commit 992f45a

Please sign in to comment.