diff --git a/packages/core/src/browser/core-preferences.ts b/packages/core/src/browser/core-preferences.ts index 8dc8ab4bb15fd..ee3be67ce51f4 100644 --- a/packages/core/src/browser/core-preferences.ts +++ b/packages/core/src/browser/core-preferences.ts @@ -198,6 +198,11 @@ export const corePreferenceSchema: PreferenceSchema = { 'Controls the feedback area size in pixels of the dragging area in between views/editors. Set it to a larger value if needed.' ) }, + 'workbench.tab.maximize': { + type: 'boolean', + default: false, + description: nls.localize('theia/core/tabMaximize', 'Controls whether to maximize tabs on double click.') + } } }; @@ -220,6 +225,7 @@ export interface CoreConfiguration { 'workbench.hover.delay': number; 'workbench.sash.hoverDelay': number; 'workbench.sash.size': number; + 'workbench.tab.maximize': boolean; } export const CorePreferenceContribution = Symbol('CorePreferenceContribution'); diff --git a/packages/core/src/browser/frontend-application-module.ts b/packages/core/src/browser/frontend-application-module.ts index 667e52624aa94..9eac3ad3196e2 100644 --- a/packages/core/src/browser/frontend-application-module.ts +++ b/packages/core/src/browser/frontend-application-module.ts @@ -178,7 +178,8 @@ export const frontendApplicationModule = new ContainerModule((bind, _unbind, _is const iconThemeService = container.get(IconThemeService); const selectionService = container.get(SelectionService); const commandService = container.get(CommandService); - return new TabBarRenderer(contextMenuRenderer, tabBarDecoratorService, iconThemeService, selectionService, commandService); + const corePreferences = container.get(CorePreferences); + return new TabBarRenderer(contextMenuRenderer, tabBarDecoratorService, iconThemeService, selectionService, commandService, corePreferences); }); bind(TheiaDockPanel.Factory).toFactory(({ container }) => options => { const corePreferences = container.get(CorePreferences); diff --git a/packages/core/src/browser/shell/tab-bars.ts b/packages/core/src/browser/shell/tab-bars.ts index bd1b2a95500e0..7afbbe67f3b1b 100644 --- a/packages/core/src/browser/shell/tab-bars.ts +++ b/packages/core/src/browser/shell/tab-bars.ts @@ -32,6 +32,7 @@ import { BreadcrumbsRenderer, BreadcrumbsRendererFactory } from '../breadcrumbs/ import { NavigatableWidget } from '../navigatable-types'; import { IDragEvent } from '@phosphor/dragdrop'; import { PINNED_CLASS } from '../widgets/widget'; +import { CorePreferences } from '../core-preferences'; /** The class name added to hidden content nodes, which are required to render vertical side bars. */ const HIDDEN_CONTENT_CLASS = 'theia-TabBar-hidden-content'; @@ -88,7 +89,8 @@ export class TabBarRenderer extends TabBar.Renderer { protected readonly decoratorService?: TabBarDecoratorService, protected readonly iconThemeService?: IconThemeService, protected readonly selectionService?: SelectionService, - protected readonly commandService?: CommandService + protected readonly commandService?: CommandService, + protected readonly corePreferences?: CorePreferences ) { super(); if (this.decoratorService) { @@ -152,6 +154,7 @@ export class TabBarRenderer extends TabBar.Renderer { { key, className, id, title: title.caption, style, dataset, oncontextmenu: this.handleContextMenuEvent, + ondblclick: this.handleDblClickEvent, onauxclick: (e: MouseEvent) => { // If user closes the tab using mouse wheel, nothing should be pasted to an active editor e.preventDefault(); @@ -481,11 +484,10 @@ export class TabBarRenderer extends TabBar.Renderer { } }; - /** - * @deprecated since 1.27.0. - * The framework no longer maximizes tabbars when performing a double-click. - */ protected handleDblClickEvent = (event: MouseEvent) => { + if (!this.corePreferences?.get('workbench.tab.maximize')) { + return; + } if (this.tabBar && event.currentTarget instanceof HTMLElement) { const id = event.currentTarget.id; // eslint-disable-next-line no-null/no-null @@ -496,6 +498,7 @@ export class TabBarRenderer extends TabBar.Renderer { } } }; + } /**