Skip to content

Commit f08007b

Browse files
committed
1 parent 07c6df1 commit f08007b

8 files changed

Lines changed: 117 additions & 92 deletions

File tree

src/vs/workbench/api/browser/viewsContainersExtensionPoint.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
9494
}
9595

9696
private handleAndRegisterCustomViewContainers() {
97+
let order = TEST_VIEW_CONTAINER_ORDER + 1;
9798
viewsContainersExtensionPoint.setHandler((extensions) => {
9899
for (let extension of extensions) {
99100
const { value, collector } = extension;
@@ -103,7 +104,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
103104
}
104105
switch (entry.key) {
105106
case 'activitybar':
106-
this.registerCustomViewContainers(entry.value, extension.description);
107+
order = this.registerCustomViewContainers(entry.value, extension.description, order);
107108
break;
108109
}
109110
});
@@ -139,12 +140,13 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
139140
return true;
140141
}
141142

142-
private registerCustomViewContainers(containers: IUserFriendlyViewsContainerDescriptor[], extension: IExtensionDescription) {
143-
containers.forEach((descriptor, index) => {
143+
private registerCustomViewContainers(containers: IUserFriendlyViewsContainerDescriptor[], extension: IExtensionDescription, order: number): number {
144+
containers.forEach(descriptor => {
144145
const cssClass = `extensionViewlet-${descriptor.id}`;
145146
const icon = resources.joinPath(extension.extensionLocation, descriptor.icon);
146-
this.registerCustomViewlet({ id: `workbench.view.extension.${descriptor.id}`, title: descriptor.title, icon }, TEST_VIEW_CONTAINER_ORDER + index + 1, cssClass, extension.id);
147+
this.registerCustomViewlet({ id: `workbench.view.extension.${descriptor.id}`, title: descriptor.title, icon }, order++, cssClass, extension.id);
147148
});
149+
return order;
148150
}
149151

150152
private registerCustomViewlet(descriptor: IUserFriendlyViewsContainerDescriptor2, order: number, cssClass: string, extensionId: string): void {

src/vs/workbench/browser/parts/activitybar/activitybarPart.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,15 @@ export class ActivitybarPart extends Part {
8787
overflowActionSize: ActivitybarPart.ACTION_HEIGHT
8888
}));
8989

90-
const previousState = this.storageService.get(ActivitybarPart.PLACEHOLDER_VIEWLETS, StorageScope.GLOBAL, void 0);
91-
if (previousState) {
92-
let parsedPreviousState = <IPlaceholderComposite[]>JSON.parse(previousState);
93-
parsedPreviousState.forEach((s) => {
94-
if (typeof s.iconUrl === 'object') {
95-
s.iconUrl = URI.revive(s.iconUrl);
96-
} else {
97-
s.iconUrl = void 0;
98-
}
99-
});
100-
this.placeholderComposites = parsedPreviousState;
101-
} else {
102-
this.placeholderComposites = this.compositeBar.getCompositesFromStorage().map(id => (<IPlaceholderComposite>{ id, iconUrl: void 0 }));
103-
}
90+
const previousState = this.storageService.get(ActivitybarPart.PLACEHOLDER_VIEWLETS, StorageScope.GLOBAL, '[]');
91+
this.placeholderComposites = <IPlaceholderComposite[]>JSON.parse(previousState);
92+
this.placeholderComposites.forEach((s) => {
93+
if (typeof s.iconUrl === 'object') {
94+
s.iconUrl = URI.revive(s.iconUrl);
95+
} else {
96+
s.iconUrl = void 0;
97+
}
98+
});
10499

105100
this.registerListeners();
106101
this.updateCompositebar();
@@ -119,15 +114,15 @@ export class ActivitybarPart extends Part {
119114
if (enabled) {
120115
this.compositeBar.addComposite(this.viewletService.getViewlet(id));
121116
} else {
122-
this.removeComposite(id);
117+
this.removeComposite(id, true);
123118
}
124119
}));
125120

126121
this._register(this.extensionService.onDidRegisterExtensions(() => this.onDidRegisterExtensions()));
127122
}
128123

129124
private onDidRegisterExtensions(): void {
130-
this.removeNotExistingPlaceholderComposites();
125+
this.removeNotExistingComposites();
131126
this.updateCompositebar();
132127
}
133128

@@ -283,17 +278,21 @@ export class ActivitybarPart extends Part {
283278
}
284279
}
285280

286-
private removeNotExistingPlaceholderComposites(): void {
287-
const viewlets = this.viewletService.getViewlets();
281+
private removeNotExistingComposites(): void {
282+
const viewlets = this.viewletService.getAllViewlets();
288283
for (const { id } of this.placeholderComposites) {
289284
if (viewlets.every(viewlet => viewlet.id !== id)) {
290-
this.removeComposite(id);
285+
this.removeComposite(id, false);
291286
}
292287
}
293288
}
294289

295-
private removeComposite(compositeId: string): void {
296-
this.compositeBar.removeComposite(compositeId);
290+
private removeComposite(compositeId: string, hide: boolean): void {
291+
if (hide) {
292+
this.compositeBar.hideComposite(compositeId);
293+
} else {
294+
this.compositeBar.removeComposite(compositeId);
295+
}
297296
const compositeActions = this.compositeActions[compositeId];
298297
if (compositeActions) {
299298
compositeActions.activityAction.dispose();
@@ -337,7 +336,7 @@ export class ActivitybarPart extends Part {
337336
}
338337

339338
shutdown(): void {
340-
const state = this.viewletService.getViewlets().map(viewlet => ({ id: viewlet.id, iconUrl: viewlet.iconUrl }));
339+
const state = this.viewletService.getAllViewlets().map(({ id, iconUrl }) => ({ id, iconUrl }));
341340
this.storageService.store(ActivitybarPart.PLACEHOLDER_VIEWLETS, JSON.stringify(state), StorageScope.GLOBAL);
342341

343342
super.shutdown();

0 commit comments

Comments
 (0)