Skip to content

Commit

Permalink
Namespace tabs settings
Browse files Browse the repository at this point in the history
Fixes #122027
  • Loading branch information
Tyriar committed Apr 23, 2021
1 parent 31c946b commit 760b84e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
10 changes: 5 additions & 5 deletions src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export function registerTerminalActions() {
order: 0,
when: ContextKeyAndExpr.create([
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
ContextKeyExpr.has('config.terminal.integrated.showTabs'),
ContextKeyExpr.has('config.terminal.integrated.tabs.enable'),
ContextKeyExpr.or(
ContextKeyExpr.and(
ContextKeyExpr.equals('config.terminal.integrated.tabs.showActiveTerminal', 'singleTerminal'),
Expand Down Expand Up @@ -1323,7 +1323,7 @@ export function registerTerminalActions() {
order: 2,
when: ContextKeyAndExpr.create([
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
ContextKeyExpr.not('config.terminal.integrated.showTabs')
ContextKeyExpr.not('config.terminal.integrated.tabs.enable')
]),
}],
description: {
Expand Down Expand Up @@ -1507,7 +1507,7 @@ export function registerTerminalActions() {
order: 3,
when: ContextKeyAndExpr.create([
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
ContextKeyExpr.not('config.terminal.integrated.showTabs')
ContextKeyExpr.not('config.terminal.integrated.tabs.enable')
]),
}
});
Expand Down Expand Up @@ -1758,7 +1758,7 @@ export function registerTerminalActions() {
return Promise.resolve(null);
}
if (item === switchTerminalShowTabsTitle) {
accessor.get(IConfigurationService).updateValue('terminal.integrated.showTabs', true);
accessor.get(IConfigurationService).updateValue('terminal.integrated.tabs.enable', true);
return;
}
const indexMatches = terminalIndexRe.exec(item);
Expand Down Expand Up @@ -1798,7 +1798,7 @@ export function registerTerminalActions() {
order: 0,
when: ContextKeyAndExpr.create([
ContextKeyEqualsExpr.create('view', TERMINAL_VIEW_ID),
ContextKeyExpr.not('config.terminal.integrated.showTabs')
ContextKeyExpr.not('config.terminal.integrated.tabs.enable')
]),
});
}
Expand Down
26 changes: 13 additions & 13 deletions src/vs/workbench/contrib/terminal/browser/terminalTabbedView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export class TerminalTabbedView extends Disposable {
this._terminalContainer.classList.add('terminal-outer-container');
this._terminalContainer.style.display = 'block';

this._tabTreeIndex = this._terminalService.configHelper.config.tabsLocation === 'left' ? 0 : 1;
this._terminalContainerIndex = this._terminalService.configHelper.config.tabsLocation === 'left' ? 1 : 0;
this._tabTreeIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 0 : 1;
this._terminalContainerIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 1 : 0;

this._findWidgetVisible = KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE.bindTo(contextKeyService);

Expand All @@ -113,11 +113,11 @@ export class TerminalTabbedView extends Disposable {
this._terminalTabsFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_TABS_FOCUS.bindTo(contextKeyService);

_configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('terminal.integrated.showTabs')) {
if (e.affectsConfiguration('terminal.integrated.tabs.enable')) {
this._refreshShowTabs();
} else if (e.affectsConfiguration('terminal.integrated.tabsLocation')) {
this._tabTreeIndex = this._terminalService.configHelper.config.tabsLocation === 'left' ? 0 : 1;
this._terminalContainerIndex = this._terminalService.configHelper.config.tabsLocation === 'left' ? 1 : 0;
} else if (e.affectsConfiguration('terminal.integrated.tabs.location')) {
this._tabTreeIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 0 : 1;
this._terminalContainerIndex = this._terminalService.configHelper.config.tabs.location === 'left' ? 1 : 0;
if (this._shouldShowTabs()) {
this._splitView.swapViews(0, 1);
this._splitView.resizeView(this._tabTreeIndex, this._getLastWidgetWidth());
Expand Down Expand Up @@ -145,9 +145,9 @@ export class TerminalTabbedView extends Disposable {
}

private _shouldShowTabs(): boolean {
const showTabs = this._terminalService.configHelper.config.showTabs;
return <any>showTabs === true || showTabs === 'on' ||
(showTabs === 'multipleTerminals' && this._terminalService.terminalInstances.length > 1);
const enable = this._terminalService.configHelper.config.tabs.enable;
const hideForSingle = this._terminalService.configHelper.config.tabs.hideForSingle;
return enable && (!hideForSingle || (hideForSingle && this._terminalService.terminalInstances.length > 1));
}

private _refreshShowTabs() {
Expand Down Expand Up @@ -477,15 +477,15 @@ export class TerminalTabbedView extends Disposable {
private _getTabActions(): Action[] {
return [
new Separator(),
this._configurationService.inspect('terminal.integrated.tabsLocation').userValue === 'left' ?
this._configurationService.inspect('terminal.integrated.tabs.location').userValue === 'left' ?
new Action('moveRight', localize('moveTabsRight', "Move Tabs Right"), undefined, undefined, async () => {
this._configurationService.updateValue('terminal.integrated.tabsLocation', 'right');
this._configurationService.updateValue('terminal.integrated.tabs.location', 'right');
}) :
new Action('moveLeft', localize('moveTabsLeft', "Move Tabs Left"), undefined, undefined, async () => {
this._configurationService.updateValue('terminal.integrated.tabsLocation', 'left');
this._configurationService.updateValue('terminal.integrated.tabs.location', 'left');
}),
new Action('hideTabs', localize('hideTabs', "Hide Tabs"), undefined, undefined, async () => {
this._configurationService.updateValue('terminal.integrated.showTabs', false);
this._configurationService.updateValue('terminal.integrated.tabs.enable', false);
})
];
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ export interface ITerminalConfiguration {
windows: string | null;
};
useWslProfiles: boolean;
showTabs: 'on' | 'multipleTerminals' | 'off';
tabsLocation: 'left' | 'right';
altClickMovesCursor: boolean;
macOptionIsMeta: boolean;
macOptionClickForcesSelection: boolean;
Expand Down Expand Up @@ -188,8 +186,10 @@ export interface ITerminalConfiguration {
localEchoStyle: 'bold' | 'dim' | 'italic' | 'underlined' | 'inverted' | string;
enablePersistentSessions: boolean;
tabs: {
enable: boolean;
hideForSingle: boolean;
showActiveTerminal: 'always' | 'singleTerminal' | 'singleTerminalOrNarrow' | 'never';
location: 'left' | 'right';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,10 @@ export const terminalConfiguration: IConfigurationNode = {
type: 'boolean',
default: true
},
'terminal.integrated.showTabs': {
// TODO: Rename to enable
description: localize('terminal.integrated.showTabs', 'Controls whether terminal tabs display as a list to the side of the terminal. When this is disabled a dropdown will display instead.'),
type: 'string',
enum: ['on', 'multipleTerminals', 'off'],
default: 'multipleTerminals',
'terminal.integrated.tabs.enable': {
description: localize('terminal.integrated.tabs.enable', 'Controls whether terminal tabs display as a list to the side of the terminal. When this is disabled a dropdown will display instead.'),
type: 'boolean',
default: true,
},
'terminal.integrated.tabs.hideForSingle': {
description: localize('terminal.integrated.tabs.hideForSingle', 'Hides the terminal tabs view when there is only a single terminal instance.'),
Expand All @@ -316,11 +314,11 @@ export const terminalConfiguration: IConfigurationNode = {
enum: ['always', 'singleTerminal', 'singleTerminalOrNarrow', 'never'],
default: 'singleTerminalOrNarrow',
},
'terminal.integrated.tabsLocation': {
'terminal.integrated.tabs.location': {
type: 'string',
enum: ['left', 'right'],
default: 'right',
description: localize('terminal.integrated.tabsLocation', "Controls the location of the terminal tabs, either to the left or right of the actual terminal(s).")
description: localize('terminal.integrated.tabs.location', "Controls the location of the terminal tabs, either to the left or right of the actual terminal(s).")
},
'terminal.integrated.macOptionIsMeta': {
description: localize('terminal.integrated.macOptionIsMeta', "Controls whether to treat the option key as the meta key in the terminal on macOS."),
Expand Down

0 comments on commit 760b84e

Please sign in to comment.