Add separator between view actions and global panel actions (fix #147903) (#255576)

This commit is contained in:
Benjamin Pasero
2025-07-12 20:59:55 +02:00
committed by GitHub
parent 0eb2ec5a87
commit 462ce94707
4 changed files with 18 additions and 1 deletions

View File

@@ -301,6 +301,11 @@ export interface IToolBarRenderOptions {
* Should the primary group allow for separators.
*/
useSeparatorsInPrimaryActions?: boolean;
/**
* Force a leading separator in the primary actions group.
*/
forceLeadingSeparatorInPrimaryActions?: boolean;
}
export interface IMenuWorkbenchToolBarOptions extends IWorkbenchToolBarOptions {
@@ -369,6 +374,9 @@ export class MenuWorkbenchToolBar extends WorkbenchToolBar {
options?.toolbarOptions?.primaryGroup, options?.toolbarOptions?.shouldInlineSubmenu, options?.toolbarOptions?.useSeparatorsInPrimaryActions
);
container.classList.toggle('has-no-actions', primary.length === 0 && secondary.length === 0);
if (options?.toolbarOptions?.forceLeadingSeparatorInPrimaryActions && primary.length > 0) {
primary.unshift(new Separator());
}
super.setActions(primary, secondary);
};

View File

@@ -12,6 +12,10 @@
margin-right: 4px;
}
.monaco-workbench .pane-composite-part > .title > .global-actions .monaco-action-bar .action-item .action-label.separator {
background-color: var(--vscode-disabledForeground);
}
.monaco-workbench .pane-composite-part > .title.has-composite-bar > .title-actions .monaco-action-bar .action-item .action-label {
outline-offset: -2px;
}

View File

@@ -110,6 +110,7 @@ export class PaneCompositeBar extends Disposable {
@IWorkbenchLayoutService protected readonly layoutService: IWorkbenchLayoutService,
) {
super();
this.location = paneCompositePart.partId === Parts.PANEL_PART
? ViewContainerLocation.Panel : paneCompositePart.partId === Parts.AUXILIARYBAR_PART
? ViewContainerLocation.AuxiliaryBar : ViewContainerLocation.Sidebar;
@@ -219,6 +220,7 @@ export class PaneCompositeBar extends Disposable {
}
private registerListeners(): void {
// View Container Changes
this._register(this.viewDescriptorService.onDidChangeViewContainers(({ added, removed }) => this.onDidChangeViewContainers(added, removed)));
this._register(this.viewDescriptorService.onDidChangeContainerLocation(({ viewContainer, from, to }) => this.onDidChangeViewContainerLocation(viewContainer, from, to)));

View File

@@ -366,7 +366,8 @@ export abstract class AbstractPaneCompositePart extends CompositePart<PaneCompos
hoverDelegate: this.toolbarHoverDelegate,
hiddenItemStrategy: HiddenItemStrategy.NoHide,
highlightToggledItems: true,
telemetrySource: this.nameForTelemetry
telemetrySource: this.nameForTelemetry,
toolbarOptions: { forceLeadingSeparatorInPrimaryActions: true /* separate from view toolbar */ }
}
));
@@ -452,11 +453,13 @@ export abstract class AbstractPaneCompositePart extends CompositePart<PaneCompos
protected override createHeaderArea(): HTMLElement {
const headerArea = super.createHeaderArea();
return this.createHeaderFooterCompositeBarArea(headerArea);
}
protected override createFooterArea(): HTMLElement {
const footerArea = super.createFooterArea();
return this.createHeaderFooterCompositeBarArea(footerArea);
}