Repository: microsoft/vscode (TypeScript)
Task: Bug Fix (2022-11-21 12:38:39+00:00)

Issue:
Views location is not getting updated when switching profiles 
- In my default profile with gitlens installed, move 3 gitlens views to a new view container (in secondary side bar)
- Create an empty profile
- Switch back to default profile
- 🐛 gitlens view are back in SCM instead of in their new view container

CC @alexr00 


Discussion:

Patch:
diff --git a/src/vs/workbench/services/views/browser/viewDescriptorService.ts b/src/vs/workbench/services/views/browser/viewDescriptorService.ts
--- a/src/vs/workbench/services/views/browser/viewDescriptorService.ts
+++ b/src/vs/workbench/services/views/browser/viewDescriptorService.ts
@@ -54,8 +54,8 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
 	private readonly viewsRegistry: IViewsRegistry;
 	private readonly viewContainersRegistry: IViewContainersRegistry;
 
-	private readonly viewContainersCustomLocations: Map<string, ViewContainerLocation>;
-	private readonly viewDescriptorsCustomLocations: Map<string, string>;
+	private viewContainersCustomLocations: Map<string, ViewContainerLocation>;
+	private viewDescriptorsCustomLocations: Map<string, string>;
 
 	private readonly _onDidChangeViewContainers = this._register(new Emitter<{ added: ReadonlyArray<{ container: ViewContainer; location: ViewContainerLocation }>; removed: ReadonlyArray<{ container: ViewContainer; location: ViewContainerLocation }> }>());
 	readonly onDidChangeViewContainers = this._onDidChangeViewContainers.event;
@@ -567,6 +567,9 @@ export class ViewDescriptorService extends Disposable implements IViewDescriptor
 		for (const { views, from, to } of viewsToMove) {
 			this.moveViewsWithoutSaving(views, from, to);
 		}
+
+		this.viewContainersCustomLocations = newViewContainerCustomizations;
+		this.viewDescriptorsCustomLocations = newViewDescriptorCustomizations;
 	}
 
 	// Generated Container Id Format


Test patch:
diff --git a/src/vs/workbench/services/views/test/browser/viewDescriptorService.test.ts b/src/vs/workbench/services/views/test/browser/viewDescriptorService.test.ts
--- a/src/vs/workbench/services/views/test/browser/viewDescriptorService.test.ts
+++ b/src/vs/workbench/services/views/test/browser/viewDescriptorService.test.ts
@@ -621,4 +621,47 @@ suite('ViewDescriptorService', () => {
 		assert.deepStrictEqual(actual, viewsCustomizations);
 	});
 
+	test('storage change also updates locations even if views do not exists and views are registered later', async function () {
+		const storageService = instantiationService.get(IStorageService);
+		const testObject = aViewDescriptorService();
+
+		const generateViewContainerId = `workbench.views.service.${ViewContainerLocationToString(ViewContainerLocation.AuxiliaryBar)}.${generateUuid()}`;
+		const viewsCustomizations = {
+			viewContainerLocations: {
+				[generateViewContainerId]: ViewContainerLocation.AuxiliaryBar,
+			},
+			viewLocations: {
+				'view1': generateViewContainerId
+			}
+		};
+		storageService.store('views.customizations', JSON.stringify(viewsCustomizations), StorageScope.PROFILE, StorageTarget.USER);
+
+		const viewContainer = ViewContainersRegistry.registerViewContainer({ id: `${viewContainerIdPrefix}-${generateUuid()}`, title: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
+		const viewDescriptors: IViewDescriptor[] = [
+			{
+				id: 'view1',
+				ctorDescriptor: null!,
+				name: 'Test View 1',
+				canMoveView: true
+			},
+			{
+				id: 'view2',
+				ctorDescriptor: null!,
+				name: 'Test View 2',
+				canMoveView: true
+			}
+		];
+		ViewsRegistry.registerViews(viewDescriptors, viewContainer);
+
+		testObject.onDidRegisterExtensions();
+
+		const viewContainer1Views = testObject.getViewContainerModel(viewContainer);
+		assert.deepStrictEqual(viewContainer1Views.allViewDescriptors.map(v => v.id), ['view2']);
+
+		const generateViewContainer = testObject.getViewContainerById(generateViewContainerId)!;
+		assert.deepStrictEqual(testObject.getViewContainerLocation(generateViewContainer), ViewContainerLocation.AuxiliaryBar);
+		const generatedViewContainerModel = testObject.getViewContainerModel(generateViewContainer);
+		assert.deepStrictEqual(generatedViewContainerModel.allViewDescriptors.map(v => v.id), ['view1']);
+	});
+
 });