File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
extensions/ql-vscode/src/local-queries Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 88 CancellationTokenSource ,
99 QuickPickItem ,
1010 Range ,
11+ TabInputText ,
1112 Uri ,
1213 window ,
1314} from "vscode" ;
@@ -300,20 +301,18 @@ export class LocalQueries extends DisposableObject {
300301 }
301302
302303 /**
303- * Gets the current active query.
304- *
305- * For now, the "active query" is just whatever query is in the active text editor. Once we have a
306- * proper "queries" panel, we can provide a way to select the current query there.
304+ * Gets the current active query. This is the query that is open in the active tab.
307305 */
308306 public async getCurrentQuery ( allowLibraryFiles : boolean ) : Promise < string > {
309- const editor = window . activeTextEditor ;
310- if ( editor === undefined ) {
307+ const input = window . tabGroups . activeTabGroup . activeTab ?. input ;
308+
309+ if ( input === undefined || ! isTabInputText ( input ) ) {
311310 throw new Error (
312311 "No query was selected. Please select a query and try again." ,
313312 ) ;
314313 }
315314
316- return validateQueryUri ( editor . document . uri , allowLibraryFiles ) ;
315+ return validateQueryUri ( input . uri , allowLibraryFiles ) ;
317316 }
318317
319318 private async createSkeletonQuery ( ) : Promise < void > {
@@ -581,3 +580,7 @@ export class LocalQueries extends DisposableObject {
581580 : [ ] ;
582581 }
583582}
583+
584+ function isTabInputText ( input : any ) : input is TabInputText {
585+ return input ?. uri !== undefined ;
586+ }
You can’t perform that action at this time.
0 commit comments