mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-26 10:16:01 +01:00
retain non existing view customizations (#159921)
This commit is contained in:
committed by
GitHub
parent
b4a53a5846
commit
5bc68cd888
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user