diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index d917d2f9a38..a34f8e71e2c 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -70,6 +70,7 @@ export class MenuId { static readonly EmptyEditorGroupContext = new MenuId('EmptyEditorGroupContext'); static readonly EditorTabsBarContext = new MenuId('EditorTabsBarContext'); static readonly EditorTabsBarShowTabsSubmenu = new MenuId('EditorTabsBarShowTabsSubmenu'); + static readonly EditorActionsPositionSubmenu = new MenuId('EditorActionsPositionSubmenu'); static readonly ExplorerContext = new MenuId('ExplorerContext'); static readonly ExplorerContextShare = new MenuId('ExplorerContextShare'); static readonly ExtensionContext = new MenuId('ExtensionContext'); diff --git a/src/vs/workbench/browser/actions/layoutActions.ts b/src/vs/workbench/browser/actions/layoutActions.ts index 76f90e4cda5..d877dea64d6 100644 --- a/src/vs/workbench/browser/actions/layoutActions.ts +++ b/src/vs/workbench/browser/actions/layoutActions.ts @@ -534,6 +534,125 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { order: 10 }); +// --- Show Editor Actions in Title Bar + +export class EditorActionsTitleBarAction extends Action2 { + + static readonly ID = 'workbench.action.editorActionsTitleBar'; + + constructor() { + super({ + id: EditorActionsTitleBarAction.ID, + title: { + value: localize('moveEditorActionsToTitleBar', "Move Editor Actions to Title Bar"), + original: 'Move Editor Actions to Title Bar' + }, + category: Categories.View, + precondition: ContextKeyExpr.and( + ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'titleBar').negate(), + ContextKeyExpr.equals('config.window.style', 'native').negate(), + ), + f1: true + }); + } + + run(accessor: ServicesAccessor): Promise { + const configurationService = accessor.get(IConfigurationService); + return configurationService.updateValue('workbench.editor.editorActionsLocation', 'titleBar'); + } +} +registerAction2(EditorActionsTitleBarAction); + +// --- Editor Actions Default Position + +export class EditorActionsDefaultAction extends Action2 { + + static readonly ID = 'workbench.action.editorActionsDefault'; + + constructor() { + super({ + id: EditorActionsDefaultAction.ID, + title: { + value: localize('moveEditorActionsToTabBar', "Move Editor Actions to Tab Bar"), + original: 'Move Editor Actions to Tab Bar' + }, + category: Categories.View, + precondition: ContextKeyExpr.and( + ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'default').negate(), + ContextKeyExpr.equals('config.workbench.editor.showTabs', 'none').negate(), + ), + f1: true + }); + } + + run(accessor: ServicesAccessor): Promise { + const configurationService = accessor.get(IConfigurationService); + return configurationService.updateValue('workbench.editor.editorActionsLocation', 'default'); + } +} +registerAction2(EditorActionsDefaultAction); + +// --- Hide Editor Actions + +export class HideEditorActionsAction extends Action2 { + + static readonly ID = 'workbench.action.hideEditorActions'; + + constructor() { + super({ + id: HideEditorActionsAction.ID, + title: { + value: localize('hideEditorActons', "Hide Editor Actions"), + original: 'Hide Editor Actions' + }, + category: Categories.View, + precondition: ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'hidden').negate(), + f1: true + }); + } + + run(accessor: ServicesAccessor): Promise { + const configurationService = accessor.get(IConfigurationService); + return configurationService.updateValue('workbench.editor.editorActionsLocation', 'hidden'); + } +} +registerAction2(HideEditorActionsAction); + +// --- Hide Editor Actions + +export class ShowEditorActionsAction extends Action2 { + + static readonly ID = 'workbench.action.showEditorActions'; + + constructor() { + super({ + id: ShowEditorActionsAction.ID, + title: { + value: localize('showEditorActons', "Show Editor Actions"), + original: 'Show Editor Actions' + }, + category: Categories.View, + precondition: ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'hidden'), + f1: true + }); + } + + run(accessor: ServicesAccessor): Promise { + const configurationService = accessor.get(IConfigurationService); + return configurationService.updateValue('workbench.editor.editorActionsLocation', 'default'); + } +} +registerAction2(ShowEditorActionsAction); + +// --- Editor Actions Position Submenu in View Appearance Menu + +MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { + submenu: MenuId.EditorActionsPositionSubmenu, + title: localize('editorActionsPosition', "Editor Actions Position"), + group: '3_workbench_layout_move', + order: 11 +}); + // --- Toggle Pinned Tabs On Separate Row registerAction2(class extends Action2 { diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index 8ebad36c34b..52bc1cf3f38 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -65,7 +65,7 @@ import { Codicon } from 'vs/base/common/codicons'; import { registerIcon } from 'vs/platform/theme/common/iconRegistry'; import { UntitledTextEditorInputSerializer, UntitledTextEditorWorkingCopyEditorHandler } from 'vs/workbench/services/untitled/common/untitledTextEditorHandler'; import { DynamicEditorConfigurations } from 'vs/workbench/browser/parts/editor/editorConfiguration'; -import { HideEditorTabsAction, ShowMultipleEditorTabsAction, ShowSingleEditorTabAction } from 'vs/workbench/browser/actions/layoutActions'; +import { EditorActionsDefaultAction, EditorActionsTitleBarAction, HideEditorActionsAction, HideEditorTabsAction, ShowMultipleEditorTabsAction, ShowSingleEditorTabAction } from 'vs/workbench/browser/actions/layoutActions'; import product from 'vs/platform/product/common/product'; import { ICommandAction } from 'vs/platform/action/common/action'; @@ -357,11 +357,17 @@ MenuRegistry.appendMenuItem(MenuId.EditorTabsBarContext, { command: { id: SPLIT_ MenuRegistry.appendMenuItem(MenuId.EditorTabsBarContext, { command: { id: SPLIT_EDITOR_DOWN, title: localize('splitDown', "Split Down") }, group: '2_split', order: 20 }); MenuRegistry.appendMenuItem(MenuId.EditorTabsBarContext, { command: { id: SPLIT_EDITOR_LEFT, title: localize('splitLeft', "Split Left") }, group: '2_split', order: 30 }); MenuRegistry.appendMenuItem(MenuId.EditorTabsBarContext, { command: { id: SPLIT_EDITOR_RIGHT, title: localize('splitRight', "Split Right") }, group: '2_split', order: 40 }); + MenuRegistry.appendMenuItem(MenuId.EditorTabsBarContext, { submenu: MenuId.EditorTabsBarShowTabsSubmenu, title: localize('tabBar', "Tab Bar"), group: '3_config', order: 10 }); MenuRegistry.appendMenuItem(MenuId.EditorTabsBarShowTabsSubmenu, { command: { id: ShowMultipleEditorTabsAction.ID, title: localize('multipleTabs', "Multiple Tabs"), toggled: ContextKeyExpr.equals('config.workbench.editor.showTabs', 'multiple') }, group: '1_config', order: 10 }); MenuRegistry.appendMenuItem(MenuId.EditorTabsBarShowTabsSubmenu, { command: { id: ShowSingleEditorTabAction.ID, title: localize('singleTab', "Single Tab"), toggled: ContextKeyExpr.equals('config.workbench.editor.showTabs', 'single') }, group: '1_config', order: 20 }); MenuRegistry.appendMenuItem(MenuId.EditorTabsBarShowTabsSubmenu, { command: { id: HideEditorTabsAction.ID, title: localize('hideTabBar', "Hide"), toggled: ContextKeyExpr.equals('config.workbench.editor.showTabs', 'none') }, group: '1_config', order: 30 }); +MenuRegistry.appendMenuItem(MenuId.EditorTabsBarContext, { submenu: MenuId.EditorActionsPositionSubmenu, title: localize('editorActionsPosition', "Editor Actions Position"), group: '3_config', order: 20 }); +MenuRegistry.appendMenuItem(MenuId.EditorActionsPositionSubmenu, { command: { id: EditorActionsDefaultAction.ID, title: localize('tabBar', "Tab Bar"), toggled: ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'default') }, group: '1_config', order: 10, when: ContextKeyExpr.equals('config.workbench.editor.showTabs', 'none').negate() }); +MenuRegistry.appendMenuItem(MenuId.EditorActionsPositionSubmenu, { command: { id: EditorActionsTitleBarAction.ID, title: localize('titleBar', "Title Bar"), toggled: ContextKeyExpr.or(ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'titleBar'), ContextKeyExpr.and(ContextKeyExpr.equals('config.workbench.editor.showTabs', 'none'), ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'default'))) }, group: '1_config', order: 20, when: ContextKeyExpr.equals('config.window.titleBarStyle', 'native').negate() }); +MenuRegistry.appendMenuItem(MenuId.EditorActionsPositionSubmenu, { command: { id: HideEditorActionsAction.ID, title: localize('hidden', "Hidden"), toggled: ContextKeyExpr.or(ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'hidden'), ContextKeyExpr.and(ContextKeyExpr.equals('config.window.titleBarStyle', 'native'), ContextKeyExpr.equals('config.workbench.editor.editorActionsLocation', 'titleBar'))) }, group: '1_config', order: 30 }); + // Editor Title Context Menu MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_EDITOR_COMMAND_ID, title: localize('close', "Close") }, group: '1_close', order: 10 }); MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID, title: localize('closeOthers', "Close Others"), precondition: EditorGroupEditorsCountContext.notEqualsTo('1') }, group: '1_close', order: 20 }); diff --git a/src/vs/workbench/browser/parts/editor/editor.ts b/src/vs/workbench/browser/parts/editor/editor.ts index 0c35bafff59..70b57dbdd41 100644 --- a/src/vs/workbench/browser/parts/editor/editor.ts +++ b/src/vs/workbench/browser/parts/editor/editor.ts @@ -51,7 +51,7 @@ export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = { splitOnDragAndDrop: true, centeredLayoutFixedWidth: false, doubleClickTabToToggleEditorGroupSizes: 'expand', - showEditorActionsInTitleBar: 'noTabs', + editorActionsLocation: 'default', wrapTabs: false, enablePreviewFromQuickOpen: false, scrollToSwitchTabs: false, @@ -150,7 +150,7 @@ function validateEditorPartOptions(options: IEditorPartOptions): IEditorPartOpti 'splitInGroupLayout': new EnumVerifier(DEFAULT_EDITOR_PART_OPTIONS['splitInGroupLayout'], ['vertical', 'horizontal']), 'splitSizing': new EnumVerifier(DEFAULT_EDITOR_PART_OPTIONS['splitSizing'], ['distribute', 'split', 'auto']), 'doubleClickTabToToggleEditorGroupSizes': new EnumVerifier(DEFAULT_EDITOR_PART_OPTIONS['doubleClickTabToToggleEditorGroupSizes'], ['maximize', 'expand', 'off']), - 'showEditorActionsInTitleBar': new EnumVerifier(DEFAULT_EDITOR_PART_OPTIONS['showEditorActionsInTitleBar'], ['noTabs', 'never']), + 'editorActionsLocation': new EnumVerifier(DEFAULT_EDITOR_PART_OPTIONS['editorActionsLocation'], ['default', 'titleBar', 'hidden']), 'autoLockGroups': new SetVerifier(DEFAULT_EDITOR_PART_OPTIONS['autoLockGroups']), 'limit': new ObjectVerifier(DEFAULT_EDITOR_PART_OPTIONS['limit'], { diff --git a/src/vs/workbench/browser/parts/editor/editorTabsControl.ts b/src/vs/workbench/browser/parts/editor/editorTabsControl.ts index 362707e380c..6f9a241d4b3 100644 --- a/src/vs/workbench/browser/parts/editor/editorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/editorTabsControl.ts @@ -96,8 +96,10 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC compact: 22 as const }; + protected editorActionsToolbarContainer: HTMLElement | undefined; private editorActionsToolbar: WorkbenchToolBar | undefined; - private editorActionsDisposables = this._register(new DisposableStore()); + private readonly editorActionsToolbarDisposables = this._register(new DisposableStore()); + private readonly editorActionsDisposables = this._register(new DisposableStore()); private resourceContext: ResourceContextKey; @@ -153,17 +155,47 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC this.updateTabHeight(); } - protected createEditorActionsToolBar(container: HTMLElement): void { + private get editorActionsEnabled(): boolean { + return this.groupsView.partOptions.editorActionsLocation === 'default' && this.groupsView.partOptions.showTabs !== 'none'; + } + + protected createEditorActionsToolBar(parent: HTMLElement, classes: string[]): void { + this.editorActionsToolbarContainer = document.createElement('div'); + this.editorActionsToolbarContainer.classList.add(...classes); + parent.appendChild(this.editorActionsToolbarContainer); + + this.handleEditorActionToolBarVisibility(this.editorActionsToolbarContainer); + } + + private handleEditorActionToolBarVisibility(container: HTMLElement): void { + const editorActionsEnabled = this.editorActionsEnabled; + const editorActionsVisible = !!this.editorActionsToolbar; + + // Create toolbar if it is enabled (and not yet created) + if (editorActionsEnabled && !editorActionsVisible) { + this.doCreateEditorActionsToolBar(container); + } + // Remove toolbar if it is not enabled (and is visible) + else if (!editorActionsEnabled && editorActionsVisible) { + this.editorActionsToolbar?.getElement().remove(); + this.editorActionsToolbar = undefined; + this.editorActionsToolbarDisposables.clear(); + this.editorActionsDisposables.clear(); + } + + container.classList.toggle('hidden', !editorActionsEnabled); + } + + private doCreateEditorActionsToolBar(container: HTMLElement): void { const context: IEditorCommandsContext = { groupId: this.groupView.id }; // Toolbar Widget - - this.editorActionsToolbar = this._register(this.instantiationService.createInstance(WorkbenchToolBar, container, { + this.editorActionsToolbar = this.editorActionsToolbarDisposables.add(this.instantiationService.createInstance(WorkbenchToolBar, container, { actionViewItemProvider: action => this.actionViewItemProvider(action), orientation: ActionsOrientation.HORIZONTAL, ariaLabel: localize('ariaLabelEditorActions', "Editor actions"), getKeyBinding: action => this.getKeybinding(action), - actionRunner: this._register(new EditorCommandsContextActionRunner(context)), + actionRunner: this.editorActionsToolbarDisposables.add(new EditorCommandsContextActionRunner(context)), anchorAlignmentProvider: () => AnchorAlignment.RIGHT, renderDropdownAsChildElement: this.renderDropdownAsChildElement, telemetrySource: 'editorPart', @@ -176,7 +208,7 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC this.editorActionsToolbar.context = context; // Action Run Handling - this._register(this.editorActionsToolbar.actionRunner.onDidRun(e => { + this.editorActionsToolbarDisposables.add(this.editorActionsToolbar.actionRunner.onDidRun(e => { // Notify for Error if (e.error && !isCancellationError(e.error)) { @@ -202,6 +234,10 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC } protected updateEditorActionsToolbar(): void { + if (!this.editorActionsEnabled) { + return; + } + this.editorActionsDisposables.clear(); const editorActions = this.groupView.createEditorActions(this.editorActionsDisposables); @@ -218,7 +254,12 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC } protected clearEditorActionsToolbar(): void { - this.editorActionsToolbar?.setActions([], []); + if (!this.editorActionsEnabled) { + return; + } + + const editorActionsToolbar = assertIsDefined(this.editorActionsToolbar); + editorActionsToolbar.setActions([], []); } protected enableGroupDragging(element: HTMLElement): void { @@ -359,6 +400,17 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC if (oldOptions.tabHeight !== newOptions.tabHeight) { this.updateTabHeight(); } + + // Update Editor Actions Toolbar + if ( + oldOptions.editorActionsLocation !== newOptions.editorActionsLocation || + oldOptions.showTabs !== newOptions.showTabs + ) { + if (this.editorActionsToolbarContainer) { + this.handleEditorActionToolBarVisibility(this.editorActionsToolbarContainer); + this.updateEditorActionsToolbar(); + } + } } abstract openEditor(editor: EditorInput): boolean; diff --git a/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css b/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css index 774237775de..f675a11075d 100644 --- a/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css +++ b/src/vs/workbench/browser/parts/editor/media/multieditortabscontrol.css @@ -445,6 +445,10 @@ height: var(--editor-group-tab-height); } +.monaco-workbench .part.editor > .content .editor-group-container > .title .editor-actions.hidden { + display: none; +} + .monaco-workbench .part.editor > .content .editor-group-container > .title .editor-actions .action-item { margin-right: 4px; } diff --git a/src/vs/workbench/browser/parts/editor/media/singleeditortabscontrol.css b/src/vs/workbench/browser/parts/editor/media/singleeditortabscontrol.css index f3a7d7b2484..d48bcc90491 100644 --- a/src/vs/workbench/browser/parts/editor/media/singleeditortabscontrol.css +++ b/src/vs/workbench/browser/parts/editor/media/singleeditortabscontrol.css @@ -97,6 +97,11 @@ height: var(--editor-group-tab-height); } +.monaco-workbench .part.editor > .content .editor-group-container > .title > .title-actions.hidden { + display: none; +} + + .monaco-workbench .part.editor > .content .editor-group-container > .title > .title-actions .action-item { margin-right: 4px; } diff --git a/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts b/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts index 9ed758b674a..7b779017488 100644 --- a/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts @@ -106,7 +106,6 @@ export class MultiEditorTabsControl extends EditorTabsControl { private titleContainer: HTMLElement | undefined; private tabsAndActionsContainer: HTMLElement | undefined; private tabsContainer: HTMLElement | undefined; - private editorToolbarContainer: HTMLElement | undefined; private tabsScrollbar: ScrollableElement | undefined; private tabSizingFixedDisposables: DisposableStore | undefined; @@ -191,13 +190,8 @@ export class MultiEditorTabsControl extends EditorTabsControl { // Tabs Container listeners this.registerTabsContainerListeners(this.tabsContainer, this.tabsScrollbar); - // Editor Toolbar Container - this.editorToolbarContainer = document.createElement('div'); - this.editorToolbarContainer.classList.add('editor-actions'); - this.tabsAndActionsContainer.appendChild(this.editorToolbarContainer); - - // Editor Actions Toolbar - this.createEditorActionsToolBar(this.editorToolbarContainer); + // Create Editor Toolbar + this.createEditorActionsToolBar(this.tabsAndActionsContainer, ['editor-actions']); // Set tabs control visibility this.updateTabsControlVisibility(); @@ -1683,7 +1677,7 @@ export class MultiEditorTabsControl extends EditorTabsControl { } private doLayoutTabsWrapping(dimensions: IEditorTitleControlDimensions): boolean { - const [tabsAndActionsContainer, tabsContainer, editorToolbarContainer, tabsScrollbar] = assertAllDefined(this.tabsAndActionsContainer, this.tabsContainer, this.editorToolbarContainer, this.tabsScrollbar); + const [tabsAndActionsContainer, tabsContainer, editorToolbarContainer, tabsScrollbar] = assertAllDefined(this.tabsAndActionsContainer, this.tabsContainer, this.editorActionsToolbarContainer, this.tabsScrollbar); // Handle wrapping tabs according to setting: // - enabled: only add class if tabs wrap and don't exceed available dimensions diff --git a/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts b/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts index 03c24053b3e..766845687d1 100644 --- a/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/singleEditorTabsControl.ts @@ -66,13 +66,8 @@ export class SingleEditorTabsControl extends EditorTabsControl { titleContainer.classList.toggle('breadcrumbs', Boolean(this.breadcrumbsControl)); this._register(toDisposable(() => titleContainer.classList.remove('breadcrumbs'))); // important to remove because the container is a shared dom node - // Right Actions Container - const actionsContainer = document.createElement('div'); - actionsContainer.classList.add('title-actions'); - titleContainer.appendChild(actionsContainer); - - // Editor actions toolbar - this.createEditorActionsToolBar(actionsContainer); + // Create editor actions toolbar + this.createEditorActionsToolBar(titleContainer, ['title-actions']); } private registerContainerListeners(titleContainer: HTMLElement): void { diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index 57fd944883f..5f438a51972 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -27,7 +27,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage'; import { Parts, IWorkbenchLayoutService, ActivityBarPosition, LayoutSettings } from 'vs/workbench/services/layout/browser/layoutService'; import { createActionViewItem, createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; import { Action2, IMenu, IMenuService, MenuId, registerAction2 } from 'vs/platform/actions/common/actions'; -import { ContextKeyExpr, ContextKeyExpression, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IHostService } from 'vs/workbench/services/host/browser/host'; import { Codicon } from 'vs/base/common/codicons'; import { getIconRegistry } from 'vs/platform/theme/common/iconRegistry'; @@ -187,7 +187,7 @@ export class TitlebarPart extends Part implements ITitleService { } if (this.titleBarStyle !== 'native' && this.actionToolBar) { - const affectsEditorActions = event.affectsConfiguration('workbench.editor.showEditorActionsInTitleBar') || event.affectsConfiguration('workbench.editor.showTabs'); + const affectsEditorActions = event.affectsConfiguration('workbench.editor.editorActionsLocation') || event.affectsConfiguration('workbench.editor.showTabs'); const affectsLayoutControl = event.affectsConfiguration('workbench.layoutControl.enabled'); const affectsActivityControl = event.affectsConfiguration(LayoutSettings.ACTIVITY_BAR_LOCATION); if (affectsEditorActions) { @@ -553,7 +553,11 @@ export class TitlebarPart extends Part implements ITitleService { } private get editorActionsEnabled(): boolean { - return this.editorGroupService.partOptions.showEditorActionsInTitleBar !== 'never' && this.editorGroupService.partOptions.showTabs === 'none'; + return this.editorGroupService.partOptions.editorActionsLocation === 'titleBar' || + ( + this.editorGroupService.partOptions.editorActionsLocation === 'default' && + this.editorGroupService.partOptions.showTabs === 'none' + ); } private get activityActionsEnabled(): boolean { @@ -604,12 +608,12 @@ export class TitlebarPart extends Part implements ITitleService { class ToogleConfigAction extends Action2 { - constructor(private readonly section: string, title: string, order: number, when?: ContextKeyExpression) { + constructor(private readonly section: string, title: string, order: number) { super({ id: `toggle.${section}`, title, toggled: ContextKeyExpr.equals(`config.${section}`, true), - menu: { id: MenuId.TitleBarContext, order, when } + menu: { id: MenuId.TitleBarContext, order } }); } @@ -632,12 +636,6 @@ registerAction2(class ToogleLayoutControl extends ToogleConfigAction { } }); -registerAction2(class ToogleEditorActionsControl extends ToogleConfigAction { - constructor() { - super('workbench.editor.showEditorActionsInTitleBar', localize('toggle.editorActions', 'Editor Actions'), 2, ContextKeyExpr.equals('config.workbench.editor.showTabs', 'none')); - } -}); - const ACCOUNTS_ACTIVITY_TILE_ACTION: IAction = { id: ACCOUNTS_ACTIVITY_ID, label: localize('accounts', "Accounts"), diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index 1c16044a043..e39f9c35dd1 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -49,15 +49,16 @@ const registry = Registry.as(ConfigurationExtensions.Con 'description': localize('showEditorTabs', "Controls whether opened editors should show as individual tabs, one single large tab or if the title area should not be shown."), 'default': 'multiple' }, - 'workbench.editor.showEditorActionsInTitleBar': { + 'workbench.editor.editorActionsLocation': { 'type': 'string', - 'enum': ['noTabs', 'never'], + 'enum': ['default', 'titleBar', 'hidden'], 'enumDescriptions': [ - localize('workbench.editor.showEditorActionsInTitleBar.noTabs', "Show editor actions in the editor title bar only when `#workbench.editor.showTabs#` is set to `none`. Otherwise, editor actions show up in the tab bar."), - localize('workbench.editor.showEditorActionsInTitleBar.never', "Do not show editor actions in the editor title bar"), + localize('workbench.editor.editorActionsLocation.default', "Show editor actions in the window title bar when `#workbench.editor.showTabs#` is set to `none`. Otherwise, editor actions are shown in the editor tab bar."), + localize('workbench.editor.editorActionsLocation.titleBar', "Show editor actions in the window title bar. If `#window.titleBarStyle#` is set to `native`, editor actions are hidden."), + localize('workbench.editor.editorActionsLocation.hidden', "Editor actions are not shown."), ], - 'markdownDescription': localize('showEditorActionsInTitleBar', "Controls whether editor actions are shown in the title bar. This value only applies when `#window.titleBarStyle#` is set to `custom`."), - 'default': 'noTabs' + 'markdownDescription': localize('editorActionsLocation', "Controls where the editor actions are shown."), + 'default': 'default' }, 'workbench.editor.wrapTabs': { 'type': 'boolean', diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index e9957f64ede..bb796afcae8 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -1147,7 +1147,7 @@ interface IEditorPartConfiguration { splitOnDragAndDrop?: boolean; centeredLayoutFixedWidth?: boolean; doubleClickTabToToggleEditorGroupSizes?: 'maximize' | 'expand' | 'off'; - showEditorActionsInTitleBar?: 'noTabs' | 'never'; + editorActionsLocation?: 'default' | 'titleBar' | 'hidden'; limit?: IEditorPartLimitConfiguration; decorations?: IEditorPartDecorationsConfiguration; }