Fix crash in codeql.debugQuery when run from command palette

This commit is contained in:
Dave Bartolomeo
2023-04-14 17:56:58 -04:00
parent 7602d8e317
commit 74c3db7392
3 changed files with 7 additions and 4 deletions

View File

@@ -150,7 +150,7 @@ export type LocalQueryCommands = {
// Debugger commands
export type DebuggerCommands = {
"codeQL.debugQuery": (uri: Uri) => Promise<void>;
"codeQL.debugQuery": (uri: Uri | undefined) => Promise<void>;
"codeQL.debugQueryContextEditor": (uri: Uri) => Promise<void>;
"codeQL.startDebuggingSelection": () => Promise<void>;
"codeQL.startDebuggingSelectionContextEditor": () => Promise<void>;

View File

@@ -185,8 +185,11 @@ export class DebuggerUI
this.sessions.delete(session.id);
}
private async debugQuery(uri: Uri): Promise<void> {
const queryPath = validateQueryUri(uri, false);
private async debugQuery(uri: Uri | undefined): Promise<void> {
const queryPath =
uri !== undefined
? validateQueryUri(uri, false)
: await this.localQueries.getCurrentQuery(false);
// Start debugging with a default configuration that just specifies the query path.
await debug.startDebugging(undefined, {

View File

@@ -412,7 +412,7 @@ export class LocalQueries extends DisposableObject {
* For now, the "active query" is just whatever query is in the active text editor. Once we have a
* propery "queries" panel, we can provide a way to select the current query there.
*/
private async getCurrentQuery(allowLibraryFiles: boolean): Promise<string> {
public async getCurrentQuery(allowLibraryFiles: boolean): Promise<string> {
const editor = window.activeTextEditor;
if (editor === undefined) {
throw new Error(