Merge pull request #2685 from github/shati-patel/get-current-query
Fix `getCurrentQuery` to look at active tabs instead of active text editors
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
CancellationTokenSource,
|
CancellationTokenSource,
|
||||||
QuickPickItem,
|
QuickPickItem,
|
||||||
Range,
|
Range,
|
||||||
|
TabInputText,
|
||||||
Uri,
|
Uri,
|
||||||
window,
|
window,
|
||||||
} from "vscode";
|
} from "vscode";
|
||||||
@@ -300,20 +301,18 @@ export class LocalQueries extends DisposableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current active query.
|
* Gets the current active query. This is the query that is open in the active tab.
|
||||||
*
|
|
||||||
* For now, the "active query" is just whatever query is in the active text editor. Once we have a
|
|
||||||
* proper "queries" panel, we can provide a way to select the current query there.
|
|
||||||
*/
|
*/
|
||||||
public async getCurrentQuery(allowLibraryFiles: boolean): Promise<string> {
|
public async getCurrentQuery(allowLibraryFiles: boolean): Promise<string> {
|
||||||
const editor = window.activeTextEditor;
|
const input = window.tabGroups.activeTabGroup.activeTab?.input;
|
||||||
if (editor === undefined) {
|
|
||||||
|
if (input === undefined || !isTabInputText(input)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"No query was selected. Please select a query and try again.",
|
"No query was selected. Please select a query and try again.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateQueryUri(editor.document.uri, allowLibraryFiles);
|
return validateQueryUri(input.uri, allowLibraryFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async createSkeletonQuery(): Promise<void> {
|
private async createSkeletonQuery(): Promise<void> {
|
||||||
@@ -581,3 +580,7 @@ export class LocalQueries extends DisposableObject {
|
|||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isTabInputText(input: any): input is TabInputText {
|
||||||
|
return input?.uri !== undefined;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user