Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixes 213334
  • Loading branch information
benibenj authored and aaronchucarroll committed Jul 10, 2024
1 parent 5e84f69 commit 576e41a
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/vs/workbench/browser/contextkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,16 @@ export class WorkbenchContextKeysHandler extends Disposable {
private registerListeners(): void {
this.editorGroupService.whenReady.then(() => {
this.updateEditorAreaContextKeys();
this.updateEditorGroupContextKeys();
this.updateActiveEditorGroupContextKeys();
this.updateVisiblePanesContextKeys();
});

this._register(this.editorService.onDidActiveEditorChange(() => this.updateEditorGroupContextKeys()));
this._register(this.editorService.onDidActiveEditorChange(() => this.updateActiveEditorGroupContextKeys()));
this._register(this.editorService.onDidVisibleEditorsChange(() => this.updateVisiblePanesContextKeys()));
this._register(this.editorGroupService.onDidAddGroup(() => this.updateEditorGroupContextKeys()));
this._register(this.editorGroupService.onDidRemoveGroup(() => this.updateEditorGroupContextKeys()));
this._register(this.editorGroupService.onDidChangeGroupIndex(() => this.updateEditorGroupContextKeys()));
this._register(this.editorGroupService.onDidChangeActiveGroup(() => this.updateEditorGroupsContextKeys()));
this._register(this.editorGroupService.onDidChangeGroupLocked(() => this.updateEditorGroupsContextKeys()));
this._register(this.editorGroupService.onDidAddGroup(() => this.updateEditorGroupsContextKeys()));
this._register(this.editorGroupService.onDidRemoveGroup(() => this.updateEditorGroupsContextKeys()));
this._register(this.editorGroupService.onDidChangeGroupIndex(() => this.updateActiveEditorGroupContextKeys()));
this._register(this.editorGroupService.onDidChangeGroupLocked(() => this.updateActiveEditorGroupContextKeys()));

this._register(this.editorGroupService.onDidChangeEditorPartOptions(() => this.updateEditorAreaContextKeys()));

Expand Down Expand Up @@ -266,16 +265,25 @@ export class WorkbenchContextKeysHandler extends Disposable {
}
}

private updateEditorGroupContextKeys(): void {
// Context keys depending on the state of the editor group itself
private updateActiveEditorGroupContextKeys(): void {
console.log('active group');
if (!this.editorService.activeEditor) {
this.activeEditorGroupEmpty.set(true);
} else {
this.activeEditorGroupEmpty.reset();
}

const activeGroup = this.editorGroupService.activeGroup;
this.activeEditorGroupIndex.set(activeGroup.index + 1); // not zero-indexed
this.activeEditorGroupLocked.set(activeGroup.isLocked);

this.updateEditorGroupsContextKeys();
}

// Context keys depending on the state of other editor groups
private updateEditorGroupsContextKeys(): void {
console.log('all groups');
const groupCount = this.editorGroupService.count;
if (groupCount > 1) {
this.multipleEditorGroupsContext.set(true);
Expand All @@ -284,9 +292,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
}

const activeGroup = this.editorGroupService.activeGroup;
this.activeEditorGroupIndex.set(activeGroup.index + 1); // not zero-indexed
this.activeEditorGroupLast.set(activeGroup.index === groupCount - 1);
this.activeEditorGroupLocked.set(activeGroup.isLocked);
}

private updateEditorAreaContextKeys(): void {
Expand Down

0 comments on commit 576e41a

Please sign in to comment.