Skip to content

Commit ffb9869

Browse files
authored
1 parent 6b9964e commit ffb9869

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/vs/workbench/services/views/common/viewContainerModel.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ class ViewDescriptorsState extends Disposable {
206206
}
207207
if (changedStates.length) {
208208
this._onDidChangeStoredState.fire(changedStates);
209+
// Update the in memory state after firing the event
210+
// so that the views can update their state accordingly
211+
for (const changedState of changedStates) {
212+
const state = this.get(changedState.id);
213+
if (state) {
214+
state.visibleGlobal = changedState.visible;
215+
}
216+
}
209217
}
210218
}
211219
}

src/vs/workbench/services/views/test/browser/viewContainerModel.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,4 +808,33 @@ suite('ViewContainerModel', () => {
808808
assert.strictEqual(target.elements[1].id, viewDescriptor3.id);
809809
}));
810810

811+
test('newly added view descriptor is hidden if it was toggled hidden in storage before adding', () => runWithFakedTimers<void>({ useFakeTimers: true }, async () => {
812+
container = ViewContainerRegistry.registerViewContainer({ id: 'test', title: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
813+
const viewDescriptor: IViewDescriptor = {
814+
id: 'view1',
815+
ctorDescriptor: null!,
816+
name: 'Test View 1',
817+
canToggleVisibility: true
818+
};
819+
storageService.store(getViewsStateStorageId('test.state'), JSON.stringify([{
820+
id: viewDescriptor.id,
821+
isHidden: false,
822+
order: undefined
823+
}]), StorageScope.PROFILE, StorageTarget.USER);
824+
825+
const testObject = viewDescriptorService.getViewContainerModel(container);
826+
827+
storageService.store(getViewsStateStorageId('test.state'), JSON.stringify([{
828+
id: viewDescriptor.id,
829+
isHidden: true,
830+
order: undefined
831+
}]), StorageScope.PROFILE, StorageTarget.USER);
832+
833+
ViewsRegistry.registerViews([viewDescriptor], container);
834+
835+
assert.strictEqual(testObject.isVisible(viewDescriptor.id), false);
836+
assert.strictEqual(testObject.activeViewDescriptors[0].id, viewDescriptor.id);
837+
assert.strictEqual(testObject.visibleViewDescriptors.length, 0);
838+
}));
839+
811840
});

0 commit comments

Comments
 (0)