Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #213334 #219669

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading