File tree Expand file tree Collapse file tree
src/data-extensions-editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 16971697 {
16981698 "id" : " codeQLModelDetails" ,
16991699 "name" : " CodeQL Model Details" ,
1700- "when" : " config.codeQL.canary && config.codeQL.dataExtensions.modelDetailsView"
1700+ "when" : " config.codeQL.canary && config.codeQL.dataExtensions.modelDetailsView && codeql.dataExtensionsEditorOpen "
17011701 }
17021702 ]
17031703 },
Original file line number Diff line number Diff line change @@ -114,11 +114,35 @@ export class DataExtensionsEditorView extends AbstractWebview<
114114 }
115115 } ) ;
116116
117- panel . onDidDispose ( async ( ) => {
117+ panel . onDidDispose ( ( ) => {
118118 this . handleViewWasDisposed ( this ) ;
119+ // onDidDispose is called after the tab has been closed,
120+ // so we want to check if there are any others still open.
121+ void this . app . commands . execute (
122+ "setContext" ,
123+ "codeql.dataExtensionsEditorOpen" ,
124+ this . isADataExtensionsEditorOpen ( ) ,
125+ ) ;
119126 } ) ;
120127
121128 await this . waitForPanelLoaded ( ) ;
129+
130+ void this . app . commands . execute (
131+ "setContext" ,
132+ "codeql.dataExtensionsEditorOpen" ,
133+ true ,
134+ ) ;
135+ }
136+
137+ private isADataExtensionsEditorOpen ( ) : boolean {
138+ return window . tabGroups . all . some ( ( tabGroup ) =>
139+ tabGroup . tabs . some ( ( tab ) => {
140+ const viewType : string | undefined = ( tab . input as any ) ?. viewType ;
141+ // The viewType has a prefix, such as "mainThreadWebview-", but if the
142+ // suffix matches that should be enough to identify the view.
143+ return viewType && viewType . endsWith ( "data-extensions-editor" ) ;
144+ } ) ,
145+ ) ;
122146 }
123147
124148 protected async getPanelConfig ( ) : Promise < WebviewPanelConfig > {
You can’t perform that action at this time.
0 commit comments