Hide modeling panel when modeling editor is active (#2851)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -106,6 +106,9 @@ export class ModelEditorView extends AbstractWebview<
|
||||
this.databaseItem,
|
||||
this.hideModeledMethods,
|
||||
);
|
||||
await this.markModelEditorAsActive();
|
||||
} else {
|
||||
await this.updateModelEditorActiveContext();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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) => {
|
||||
@@ -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;
|
||||
// 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",
|
||||
|
||||
Reference in New Issue
Block a user