private onDidStorageChange(e: IStorageValueChangeEvent): void { if (e.key === ViewDescriptorService.CACHED_VIEW_POSITIONS && e.scope === StorageScope.GLOBAL && this.cachedViewPositionsValue !== this.getStoredCachedViewPositionsValue() /* This checks if current window changed the value or not */) { <del> this._cachedViewPositionsValue = this.getStoredCachedViewPositionsValue(); </del> <ins> this.onDidCachedViewPositionsStorageChange(); } </ins> <del> const newCachedPositions = this.getCachedViewPositions(); const viewsToMove: { views: IViewDescriptor[]; from: ViewContainer; to: ViewContainer }[] = []; </del> <ins> if (e.key === ViewDescriptorService.CACHED_VIEW_CONTAINER_LOCATIONS && e.scope === StorageScope.GLOBAL && this.cachedViewContainerLocationsValue !== this.getStoredCachedViewContainerLocationsValue() /* This checks if current window changed the value or not */) { this.onDidCachedViewContainerLocationsStorageChange(); } } </ins> <del> for (let viewId of newCachedPositions.keys()) { const viewDescriptor = this.getViewDescriptorById(viewId); if (!viewDescriptor) { continue; } </del> <ins> private onDidCachedViewPositionsStorageChange(): void { this._cachedViewPositionsValue = this.getStoredCachedViewPositionsValue(); </ins> <del> const prevViewContainer = this.getViewContainerByViewId(viewId); const newViewContainerInfo = newCachedPositions.get(viewId)!; // Verify if we need to create the destination container if (!this.viewContainersRegistry.get(newViewContainerInfo.containerId)) { const location = this.cachedViewContainerInfo.get(newViewContainerInfo.containerId); if (location !== undefined) { this.registerGeneratedViewContainer(location, newViewContainerInfo.containerId); } </del> <ins> const newCachedPositions = this.getCachedViewPositions(); const viewsToMove: { views: IViewDescriptor[]; from: ViewContainer; to: ViewContainer }[] = []; for (let viewId of newCachedPositions.keys()) { const viewDescriptor = this.getViewDescriptorById(viewId); if (!viewDescriptor) { continue; } const prevViewContainer = this.getViewContainerByViewId(viewId); const newViewContainerInfo = newCachedPositions.get(viewId)!; // Verify if we need to create the destination container if (!this.viewContainersRegistry.get(newViewContainerInfo.containerId)) { const location = this.cachedViewContainerInfo.get(newViewContainerInfo.containerId); if (location !== undefined) { this.registerGeneratedViewContainer(location, newViewContainerInfo.containerId); </ins> } <ins> } </ins> <del> // Try moving to the new container const newViewContainer = this.viewContainersRegistry.get(newViewContainerInfo.containerId); if (prevViewContainer && newViewContainer && newViewContainer !== prevViewContainer) { const viewDescriptor = this.getViewDescriptorById(viewId); if (viewDescriptor) { viewsToMove.push({ views: [viewDescriptor], from: prevViewContainer, to: newViewContainer }); } </del> <ins> // Try moving to the new container const newViewContainer = this.viewContainersRegistry.get(newViewContainerInfo.containerId); if (prevViewContainer && newViewContainer && newViewContainer !== prevViewContainer) { const viewDescriptor = this.getViewDescriptorById(viewId); if (viewDescriptor) { viewsToMove.push({ views: [viewDescriptor], from: prevViewContainer, to: newViewContainer }); </ins> } } <ins> } </ins> <del> // If a value is not present in the cache, it must be reset to default this.viewContainers.forEach(viewContainer => { const viewContainerModel = this.getViewContainerModel(viewContainer); viewContainerModel.allViewDescriptors.forEach(viewDescriptor => { if (!newCachedPositions.has(viewDescriptor.id)) { const currentContainer = this.getViewContainerByViewId(viewDescriptor.id); const defaultContainer = this.getDefaultContainerById(viewDescriptor.id); if (currentContainer && defaultContainer && currentContainer !== defaultContainer) { viewsToMove.push({ views: [viewDescriptor], from: currentContainer, to: defaultContainer }); } </del> <ins> // If a value is not present in the cache, it must be reset to default this.viewContainers.forEach(viewContainer => { const viewContainerModel = this.getViewContainerModel(viewContainer); viewContainerModel.allViewDescriptors.forEach(viewDescriptor => { if (!newCachedPositions.has(viewDescriptor.id)) { const currentContainer = this.getViewContainerByViewId(viewDescriptor.id); const defaultContainer = this.getDefaultContainerById(viewDescriptor.id); if (currentContainer && defaultContainer && currentContainer !== defaultContainer) { viewsToMove.push({ views: [viewDescriptor], from: currentContainer, to: defaultContainer }); </ins> } <del> }); </del> <ins> } </ins> }); <ins> }); </ins> <del> this.cachedViewInfo = newCachedPositions; for (const { views, from, to } of viewsToMove) { this.moveViews(views, from, to); } </del> <ins> this.cachedViewInfo = newCachedPositions; for (const { views, from, to } of viewsToMove) { this.moveViews(views, from, to); </ins> } <ins> } </ins> <del> if (e.key === ViewDescriptorService.CACHED_VIEW_CONTAINER_LOCATIONS && e.scope === StorageScope.GLOBAL && this.cachedViewContainerLocationsValue !== this.getStoredCachedViewContainerLocationsValue() /* This checks if current window changed the value or not */) { this._cachedViewContainerLocationsValue = this.getStoredCachedViewContainerLocationsValue(); const newCachedLocations = this.getCachedViewContainerLocations(); const viewContainersToMove: [ViewContainer, ViewContainerLocation][] = []; for (const [containerId, location] of newCachedLocations.entries()) { const container = this.getViewContainerById(containerId); if (container) { if (location !== this.getViewContainerLocation(container)) { viewContainersToMove.push([container, location]); } </del> <ins> private onDidCachedViewContainerLocationsStorageChange(): void { this._cachedViewContainerLocationsValue = this.getStoredCachedViewContainerLocationsValue(); const newCachedLocations = this.getCachedViewContainerLocations(); const viewContainersToMove: [ViewContainer, ViewContainerLocation][] = []; for (const [containerId, location] of newCachedLocations.entries()) { const container = this.getViewContainerById(containerId); if (container) { if (location !== this.getViewContainerLocation(container)) { viewContainersToMove.push([container, location]); </ins> } } <ins> } </ins> <del> this.viewContainers.forEach(viewContainer => { if (!newCachedLocations.has(viewContainer.id)) { const currentLocation = this.getViewContainerLocation(viewContainer); const defaultLocation = this.getDefaultViewContainerLocation(viewContainer); </del> <ins> this.viewContainers.forEach(viewContainer => { if (!newCachedLocations.has(viewContainer.id)) { const currentLocation = this.getViewContainerLocation(viewContainer); const defaultLocation = this.getDefaultViewContainerLocation(viewContainer); </ins> <del> if (currentLocation !== defaultLocation) { viewContainersToMove.push([viewContainer, defaultLocation]); } </del> <ins> if (currentLocation !== defaultLocation) { viewContainersToMove.push([viewContainer, defaultLocation]); </ins> } <del> }); // Execute View Container Movement for (const [container, location] of viewContainersToMove) { this.moveViewContainerToLocation(container, location); </del> } <ins> }); </ins> <del> this.cachedViewContainerInfo = this.getCachedViewContainerLocations(); </del> <ins> // Execute View Container Movement for (const [container, location] of viewContainersToMove) { this.moveViewContainerToLocation(container, location); </ins> } <ins> this.cachedViewContainerInfo = this.getCachedViewContainerLocations(); </ins> } // Generated Container Id Format