diff --git a/src/vs/platform/actions/browser/toolbar.ts b/src/vs/platform/actions/browser/toolbar.ts index e0a3a879b20..dd9b5487dcd 100644 --- a/src/vs/platform/actions/browser/toolbar.ts +++ b/src/vs/platform/actions/browser/toolbar.ts @@ -63,9 +63,11 @@ export type IWorkbenchToolBarOptions = IToolBarOptions & { allowContextMenu?: never; /** - * Maximun number of items that can shown. Extra items will be shown in the overflow menu. + * Controls the overflow behavior of the primary group of toolbar. This isthe maximum number of items and id of + * items that should never overflow + * */ - maxNumberOfItems?: number; + overflowBehavior?: { maxItems: number; exempted?: string[] }; }; /** @@ -150,14 +152,22 @@ export class WorkbenchToolBar extends ToolBar { } // count for max - if (this._options?.maxNumberOfItems !== undefined) { + if (this._options?.overflowBehavior !== undefined) { + + const exempted = new Set(this._options.overflowBehavior.exempted); + const maxItems = this._options.overflowBehavior.maxItems - exempted.size; + let count = 0; for (let i = 0; i < primary.length; i++) { const action = primary[i]; if (!action) { continue; } - if (++count >= this._options.maxNumberOfItems) { + count++; + if (exempted.has(action.id)) { + continue; + } + if (count >= maxItems) { primary[i] = undefined!; extraSecondary[i] = action; } diff --git a/src/vs/workbench/browser/parts/editor/editorTabsControl.ts b/src/vs/workbench/browser/parts/editor/editorTabsControl.ts index f353b458a48..3b15fef6464 100644 --- a/src/vs/workbench/browser/parts/editor/editorTabsControl.ts +++ b/src/vs/workbench/browser/parts/editor/editorTabsControl.ts @@ -39,6 +39,7 @@ import { DraggedTreeItemsIdentifier } from 'vs/editor/common/services/treeViewsD import { IEditorResolverService } from 'vs/workbench/services/editor/common/editorResolverService'; import { IEditorTitleControlDimensions } from 'vs/workbench/browser/parts/editor/editorTitleControl'; import { IReadonlyEditorGroupModel } from 'vs/workbench/common/editor/editorGroupModel'; +import { CLOSE_EDITOR_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands'; export interface IToolbarActions { readonly primary: IAction[]; @@ -173,7 +174,7 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC renderDropdownAsChildElement: this.renderDropdownAsChildElement, telemetrySource: 'editorPart', resetMenu: MenuId.EditorTitle, - maxNumberOfItems: 9, + overflowBehavior: { maxItems: 9, exempted: [CLOSE_EDITOR_COMMAND_ID] }, highlightToggledItems: true, }));