Skip to content

Commit 0672133

Browse files
committed
Ensure query text shows for empty selections
Fixes a bug where quick eval was showing empty query text. Previously, `getQueryText` was looking up the query text when it was called if the specified text was empty. This was removed with the recent changes to query history. It was also a bug since the query file could have changed after the query was run. This change ensures that if the quick eval position is empty, the entire line is returned as the quick eval location.
1 parent c0de99b commit 0672133

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,13 @@ export async function determineSelectedQuery(selectedResourceUri: Uri | undefine
542542
throw new Error('The selected resource for quick evaluation should match the active editor.');
543543
}
544544
quickEvalPosition = await getSelectedPosition(editor, range);
545-
quickEvalText = editor.document.getText(editor.selection);
545+
if (!editor.selection?.isEmpty) {
546+
quickEvalText = editor.document.getText(editor.selection);
547+
} else {
548+
// capture the entire line if the user didn't select anything
549+
const line = editor.document.lineAt(editor.selection.active.line);
550+
quickEvalText = line.text.trim();
551+
}
546552
}
547553

548554
return { queryPath, quickEvalPosition, quickEvalText };

0 commit comments

Comments
 (0)