Update group context keys on reload (#201277)

This commit is contained in:
Benjamin Simmonds 2023-12-20 12:22:45 +01:00 committed by GitHub
parent ce2710416a
commit d32043d8b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -281,7 +281,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
};
// Update group contexts based on group changes
this._register(this.onDidModelChange(e => {
const updateGroupContextKeys = (e: IGroupModelChangeEvent) => {
switch (e.kind) {
case GroupModelChangeKind.GROUP_LOCKED:
groupLockedContext.set(this.isLocked);
@ -312,16 +312,18 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Group editors count context
groupEditorsCountContext.set(this.count);
}));
};
this._register(this.onDidModelChange(e => updateGroupContextKeys(e)));
// Track the active editor and update context key that reflects
// the dirty state of this editor
this._register(this.onDidActiveEditorChange(() => {
observeActiveEditor();
}));
this._register(this.onDidActiveEditorChange(() => observeActiveEditor()));
// Update context keys on startup
observeActiveEditor();
updateGroupContextKeys({ kind: GroupModelChangeKind.EDITOR_ACTIVE });
updateGroupContextKeys({ kind: GroupModelChangeKind.GROUP_LOCKED });
}
private registerContainerListeners(): void {