mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
Merge pull request #193767 from microsoft/joh/disgusted-dolphin
WorkbenchToolBar allows to configure exemption from overflow logic
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user