Skip to content

Commit 74c3db7

Browse files
author
Dave Bartolomeo
committed
Fix crash in codeql.debugQuery when run from command palette
1 parent 7602d8e commit 74c3db7

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

extensions/ql-vscode/src/common/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export type LocalQueryCommands = {
150150

151151
// Debugger commands
152152
export type DebuggerCommands = {
153-
"codeQL.debugQuery": (uri: Uri) => Promise<void>;
153+
"codeQL.debugQuery": (uri: Uri | undefined) => Promise<void>;
154154
"codeQL.debugQueryContextEditor": (uri: Uri) => Promise<void>;
155155
"codeQL.startDebuggingSelection": () => Promise<void>;
156156
"codeQL.startDebuggingSelectionContextEditor": () => Promise<void>;

extensions/ql-vscode/src/debugger/debugger-ui.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ export class DebuggerUI
185185
this.sessions.delete(session.id);
186186
}
187187

188-
private async debugQuery(uri: Uri): Promise<void> {
189-
const queryPath = validateQueryUri(uri, false);
188+
private async debugQuery(uri: Uri | undefined): Promise<void> {
189+
const queryPath =
190+
uri !== undefined
191+
? validateQueryUri(uri, false)
192+
: await this.localQueries.getCurrentQuery(false);
190193

191194
// Start debugging with a default configuration that just specifies the query path.
192195
await debug.startDebugging(undefined, {

extensions/ql-vscode/src/local-queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ export class LocalQueries extends DisposableObject {
412412
* For now, the "active query" is just whatever query is in the active text editor. Once we have a
413413
* propery "queries" panel, we can provide a way to select the current query there.
414414
*/
415-
private async getCurrentQuery(allowLibraryFiles: boolean): Promise<string> {
415+
public async getCurrentQuery(allowLibraryFiles: boolean): Promise<string> {
416416
const editor = window.activeTextEditor;
417417
if (editor === undefined) {
418418
throw new Error(

0 commit comments

Comments
 (0)