Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/vs/workbench/services/views/browser/viewDescriptorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,23 +588,24 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor

for (const [containerId, location] of this.viewContainersCustomLocations) {
const container = this.getViewContainerById(containerId);
// Save only if the view container exists and
// the view container is generated or not at default location
if (container && (this.isGeneratedContainerId(containerId) || location !== this.getDefaultViewContainerLocation(container))) {
viewCustomizations.viewContainerLocations[containerId] = location;
// Skip if the view container is not a generated container and in default location
if (container && !this.isGeneratedContainerId(containerId) && location === this.getDefaultViewContainerLocation(container)) {
continue;
}
viewCustomizations.viewContainerLocations[containerId] = location;
}

for (const viewContainer of this.viewContainers) {
const viewContainerModel = this.getViewContainerModel(viewContainer);
for (const viewDescriptor of viewContainerModel.allViewDescriptors) {
const defaultContainer = this.getDefaultContainerById(viewDescriptor.id);
// Save only if the view is not in the default container
for (const [viewId, viewContainerId] of this.viewDescriptorsCustomLocations) {
const viewContainer = this.getViewContainerById(viewContainerId);
if (viewContainer) {
const defaultContainer = this.getDefaultContainerById(viewId);
// Skip if the view is at default location
// https://github.com/microsoft/vscode/issues/90414
if (defaultContainer?.id !== viewContainer.id) {
viewCustomizations.viewLocations[viewDescriptor.id] = viewContainer.id;
if (defaultContainer?.id === viewContainer.id) {
continue;
}
}
viewCustomizations.viewLocations[viewId] = viewContainerId;
}

this.viewCustomizations = viewCustomizations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,4 +584,41 @@ suite('ViewDescriptorService', () => {
assert.deepStrictEqual(viewContainer1Views.allViewDescriptors.map(v => v.id), ['view4']);
});

test('view containers with not existing views are not removed from customizations', async function () {
const storageService = instantiationService.get(IStorageService);
const viewContainer1 = ViewContainersRegistry.registerViewContainer({ id: `${viewContainerIdPrefix}-${generateUuid()}`, title: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
const generateViewContainer1 = `workbench.views.service.${ViewContainerLocationToString(ViewContainerLocation.Sidebar)}.${generateUuid()}`;
const viewsCustomizations = {
viewContainerLocations: {
[generateViewContainer1]: ViewContainerLocation.Sidebar,
[viewContainer1.id]: ViewContainerLocation.AuxiliaryBar
},
viewLocations: {
'view5': generateViewContainer1
}
};
storageService.store('views.customizations', JSON.stringify(viewsCustomizations), StorageScope.PROFILE, StorageTarget.USER);

const viewDescriptors: IViewDescriptor[] = [
{
id: 'view1',
ctorDescriptor: null!,
name: 'Test View 1',
canMoveView: true
}
];

ViewsRegistry.registerViews(viewDescriptors, viewContainer1);

const testObject = aViewDescriptorService();
testObject.onDidRegisterExtensions();

const viewContainer1Views = testObject.getViewContainerModel(viewContainer1);
assert.deepStrictEqual(testObject.getViewContainerLocation(viewContainer1), ViewContainerLocation.AuxiliaryBar);
assert.deepStrictEqual(viewContainer1Views.allViewDescriptors.map(v => v.id), ['view1']);

const actual = JSON.parse(storageService.get('views.customizations', StorageScope.PROFILE)!);
assert.deepStrictEqual(actual, viewsCustomizations);
});

});