Skip to content

Commit

Permalink
fix #132876
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Sep 13, 2021
1 parent f52247a commit 01021fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const cwd = this._cwd || this._initialCwd || '';
const properties = {
cwd,
cwdFolder: this._getCwdFolder(this._initialCwd, cwd),
cwdFolder: this.getCwdFolder(),
workspaceFolder: path.basename(cwd),
local: this.shellLaunchConfig.description === 'Local' ? 'Local' : undefined,
process: this._processName || title,
Expand All @@ -1826,7 +1826,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._onTitleChanged.fire(this);
}

private _getCwdFolder(initialCwd?: string, cwd?: string): string {
getCwdFolder(): string {
const initialCwd = this._initialCwd;
const cwd = this._cwd || this._initialCwd;
const singleRootWorkspace = this._workspaceContextService.getWorkspace().folders.length <= 1;
if (!cwd || !this._capabilities.includes(ProcessCapability.CwdDetection) || (singleRootWorkspace && initialCwd === cwd)) {
return '';
Expand Down
16 changes: 8 additions & 8 deletions src/vs/workbench/contrib/terminal/browser/terminalView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
super(new MenuItemAction(
{
id: action.id,
title: getSingleTabLabel(_terminalGroupService.activeInstance),
tooltip: getSingleTabTooltip(_terminalGroupService.activeInstance)
title: getSingleTabLabel(_terminalGroupService.activeInstance, _terminalService.configHelper.config.tabs.separator),
tooltip: getSingleTabTooltip(_terminalGroupService.activeInstance, _terminalService.configHelper.config.tabs.separator)
},
{
id: TerminalCommandId.Split,
Expand All @@ -376,7 +376,7 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
this._register(this._terminalService.onDidChangeInstanceColor(e => this.updateLabel(e)));
this._register(this._terminalService.onDidChangeInstanceTitle(e => {
if (e === this._terminalGroupService.activeInstance) {
this._action.tooltip = getSingleTabTooltip(e);
this._action.tooltip = getSingleTabTooltip(e, this._terminalService.configHelper.config.tabs.separator);
this.updateLabel();
}
}));
Expand Down Expand Up @@ -444,7 +444,7 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
}
}
label.style.color = colorStyle;
dom.reset(label, ...renderLabelWithIcons(getSingleTabLabel(instance, ThemeIcon.isThemeIcon(this._commandAction.item.icon) ? this._commandAction.item.icon : undefined)));
dom.reset(label, ...renderLabelWithIcons(getSingleTabLabel(instance, this._terminalService.configHelper.config.tabs.separator, ThemeIcon.isThemeIcon(this._commandAction.item.icon) ? this._commandAction.item.icon : undefined)));

if (this._altCommand) {
label.classList.remove(this._altCommand);
Expand Down Expand Up @@ -486,14 +486,14 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
}
}

function getSingleTabLabel(instance: ITerminalInstance | undefined, icon?: ThemeIcon) {
function getSingleTabLabel(instance: ITerminalInstance | undefined, separator: string, icon?: ThemeIcon) {
// Don't even show the icon if there is no title as the icon would shift around when the title
// is added
if (!instance || !instance.title) {
return '';
}
let iconClass = ThemeIcon.isThemeIcon(instance.icon) ? instance.icon?.id : Codicon.terminal.id;
const label = `$(${icon?.id || iconClass}) ${getSingleTabTooltip(instance)}`;
const label = `$(${icon?.id || iconClass}) ${getSingleTabTooltip(instance, separator)}`;

const primaryStatus = instance.statusList.primary;
if (!primaryStatus?.icon) {
Expand All @@ -502,14 +502,14 @@ function getSingleTabLabel(instance: ITerminalInstance | undefined, icon?: Theme
return `${label} $(${primaryStatus.icon.id})`;
}

function getSingleTabTooltip(instance: ITerminalInstance | undefined): string {
function getSingleTabTooltip(instance: ITerminalInstance | undefined, separator: string): string {
if (!instance) {
return '';
}
if (!instance.description) {
return instance.title;
}
return `${instance.title} ${instance.description}`;
return `${instance.title} ${separator} ${instance.description}`;
}

class TerminalThemeIconStyle extends Themable {
Expand Down

0 comments on commit 01021fd

Please sign in to comment.