Skip to content

Commit

Permalink
fixes #213334 (#219669)
Browse files Browse the repository at this point in the history
fixes 213334
  • Loading branch information
benibenj authored Jul 2, 2024
1 parent c1f025d commit c57f7bb
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

1 comment on commit c57f7bb

@bpasero
Copy link
Member

@bpasero bpasero commented on c57f7bb Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benibenj stray console.log

Please sign in to comment.