Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,7 @@
"type": "webview",
"id": "codeQLMethodModeling",
"name": "CodeQL Method Modeling",
"when": "config.codeQL.canary && config.codeQL.model.methodModelingView && codeql.modelEditorOpen"
"when": "config.codeQL.canary && config.codeQL.model.methodModelingView && codeql.modelEditorOpen && !codeql.modelEditorActive"
}
]
},
Expand Down
30 changes: 30 additions & 0 deletions extensions/ql-vscode/src/model-editor/model-editor-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export class ModelEditorView extends AbstractWebview<
this.databaseItem,
this.hideModeledMethods,
);
await this.markModelEditorAsActive();
} else {
await this.updateModelEditorActiveContext();
}
});

Expand All @@ -129,6 +132,22 @@ export class ModelEditorView extends AbstractWebview<
);
}

private async markModelEditorAsActive(): Promise<void> {
void this.app.commands.execute(
"setContext",
"codeql.modelEditorActive",
true,
);
}

private async updateModelEditorActiveContext(): Promise<void> {
await this.app.commands.execute(
"setContext",
"codeql.modelEditorActive",
this.isAModelEditorActive(),
);
}

private isAModelEditorOpen(): boolean {
return window.tabGroups.all.some((tabGroup) =>
tabGroup.tabs.some((tab) => {
Expand All @@ -140,6 +159,17 @@ export class ModelEditorView extends AbstractWebview<
);
}

private isAModelEditorActive(): boolean {
return window.tabGroups.all.some((tabGroup) =>
tabGroup.tabs.some((tab) => {
const viewType: string | undefined = (tab.input as any)?.viewType;
Comment thread
charisk marked this conversation as resolved.
// The viewType has a prefix, such as "mainThreadWebview-", but if the
// suffix matches that should be enough to identify the view.
return viewType && viewType.endsWith("model-editor") && tab.isActive;
}),
);
}

protected async getPanelConfig(): Promise<WebviewPanelConfig> {
return {
viewId: "model-editor",
Expand Down