提交 e929a1cb 编写于 作者: I isidor

composite bar: respect order of composites when adding

fixes #44306
上级 cb845480
...@@ -24,7 +24,7 @@ export interface ICompositeBarOptions { ...@@ -24,7 +24,7 @@ export interface ICompositeBarOptions {
icon: boolean; icon: boolean;
storageId: string; storageId: string;
orientation: ActionsOrientation; orientation: ActionsOrientation;
composites: { id: string, name: string }[]; composites: { id: string, name: string, order: number }[];
colors: ICompositeBarColors; colors: ICompositeBarColors;
overflowActionSize: number; overflowActionSize: number;
getActivityAction: (compositeId: string) => ActivityAction; getActivityAction: (compositeId: string) => ActivityAction;
...@@ -81,13 +81,16 @@ export class CompositeBar implements ICompositeBar { ...@@ -81,13 +81,16 @@ export class CompositeBar implements ICompositeBar {
return this._onDidContextMenu.event; return this._onDidContextMenu.event;
} }
public addComposite(compositeData: { id: string; name: string }): void { public addComposite(compositeData: { id: string; name: string, order: number }): void {
if (this.options.composites.filter(c => c.id === compositeData.id).length) { if (this.options.composites.filter(c => c.id === compositeData.id).length) {
return; return;
} }
let i = 0;
while (i < this.options.composites.length && this.options.composites[i].order < compositeData.order) {
i++;
}
this.options.composites.push(compositeData); this.options.composites.push(compositeData);
this.pin(compositeData.id); this.pin(compositeData.id, true, i);
} }
public removeComposite(id: string): void { public removeComposite(id: string): void {
...@@ -431,13 +434,13 @@ export class CompositeBar implements ICompositeBar { ...@@ -431,13 +434,13 @@ export class CompositeBar implements ICompositeBar {
return this.pinnedComposites.indexOf(compositeId) >= 0; return this.pinnedComposites.indexOf(compositeId) >= 0;
} }
public pin(compositeId: string, update = true): void { public pin(compositeId: string, update = true, index = this.pinnedComposites.length): void {
if (this.isPinned(compositeId)) { if (this.isPinned(compositeId)) {
return; return;
} }
this.options.openComposite(compositeId).then(() => { this.options.openComposite(compositeId).then(() => {
this.pinnedComposites.push(compositeId); this.pinnedComposites.splice(index, 0, compositeId);
this.pinnedComposites = arrays.distinct(this.pinnedComposites); this.pinnedComposites = arrays.distinct(this.pinnedComposites);
if (update) { if (update) {
......
...@@ -12,7 +12,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; ...@@ -12,7 +12,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
import { IPanel } from 'vs/workbench/common/panel'; import { IPanel } from 'vs/workbench/common/panel';
import { CompositePart, ICompositeTitleLabel } from 'vs/workbench/browser/parts/compositePart'; import { CompositePart, ICompositeTitleLabel } from 'vs/workbench/browser/parts/compositePart';
import { Panel, PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel'; import { Panel, PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
import { IPanelService, IPanelIdentifier } from 'vs/workbench/services/panel/common/panelService'; import { IPanelService, IPanelIdentifier } from 'vs/workbench/services/panel/common/panelService';
import { IPartService, Parts, Position } from 'vs/workbench/services/part/common/partService'; import { IPartService, Parts, Position } from 'vs/workbench/services/part/common/partService';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
...@@ -169,7 +169,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService { ...@@ -169,7 +169,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}); });
} }
public getPanels(): IPanelIdentifier[] { public getPanels(): PanelDescriptor[] {
return Registry.as<PanelRegistry>(PanelExtensions.Panels).getPanels() return Registry.as<PanelRegistry>(PanelExtensions.Panels).getPanels()
.filter(p => p.enabled) .filter(p => p.enabled)
.sort((v1, v2) => v1.order - v2.order); .sort((v1, v2) => v1.order - v2.order);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册