Skip to content

Commit 288a2bf

Browse files
Convert handleShowQueryText to use createSingleSelectionCommand
1 parent b2f0e2e commit 288a2bf

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

extensions/ql-vscode/src/query-history/query-history-manager.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ export class QueryHistoryManager extends DisposableObject {
268268
this.handleShowQueryLog.bind(this),
269269
"query",
270270
),
271-
"codeQLQueryHistory.showQueryText": this.handleShowQueryText.bind(this),
271+
"codeQLQueryHistory.showQueryText": createSingleSelectionCommand(
272+
this.handleShowQueryText.bind(this),
273+
"query",
274+
),
272275
"codeQLQueryHistory.openQueryDirectory": createSingleSelectionCommand(
273276
this.handleOpenQueryDirectory.bind(this),
274277
"query",
@@ -811,31 +814,20 @@ export class QueryHistoryManager extends DisposableObject {
811814
await Promise.all(results);
812815
}
813816

814-
async handleShowQueryText(
815-
singleItem: QueryHistoryInfo,
816-
multiSelect: QueryHistoryInfo[] = [],
817-
) {
818-
if (!this.assertSingleQuery(multiSelect)) {
819-
return;
820-
}
821-
822-
if (singleItem.t === "variant-analysis") {
823-
await this.variantAnalysisManager.openQueryText(
824-
singleItem.variantAnalysis.id,
825-
);
817+
async handleShowQueryText(item: QueryHistoryInfo) {
818+
if (item.t === "variant-analysis") {
819+
await this.variantAnalysisManager.openQueryText(item.variantAnalysis.id);
826820
return;
827821
}
828822

829823
const params = new URLSearchParams({
830824
isQuickEval: String(
831-
!!(
832-
singleItem.t === "local" && singleItem.initialInfo.quickEvalPosition
833-
),
825+
!!(item.t === "local" && item.initialInfo.quickEvalPosition),
834826
),
835-
queryText: encodeURIComponent(getQueryText(singleItem)),
827+
queryText: encodeURIComponent(getQueryText(item)),
836828
});
837829

838-
const queryId = getQueryId(singleItem);
830+
const queryId = getQueryId(item);
839831

840832
const uri = Uri.parse(`codeql:${queryId}.ql?${params.toString()}`, true);
841833
const doc = await workspace.openTextDocument(uri);

extensions/ql-vscode/test/vscode-tests/no-workspace/query-history/variant-analysis-history.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe("Variant Analyses and QueryHistoryManager", () => {
183183

184184
it("should get the query text", async () => {
185185
await qhm.readQueryHistory();
186-
await qhm.handleShowQueryText(qhm.treeDataProvider.allHistory[0], []);
186+
await qhm.handleShowQueryText(qhm.treeDataProvider.allHistory[0]);
187187

188188
expect(openQueryTextSpy).toHaveBeenCalledWith(
189189
rawQueryHistory[0].variantAnalysis.id,

0 commit comments

Comments
 (0)