Skip to content

Commit a6a2f97

Browse files
Convert handleCopyRepoList to use createSingleSelectionCommand
1 parent be6f356 commit a6a2f97

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ export class QueryHistoryManager extends DisposableObject {
304304
this.handleOpenOnGithub.bind(this),
305305
"query",
306306
),
307-
"codeQLQueryHistory.copyRepoList": this.handleCopyRepoList.bind(this),
307+
"codeQLQueryHistory.copyRepoList": createSingleSelectionCommand(
308+
this.handleCopyRepoList.bind(this),
309+
"query",
310+
),
308311

309312
"codeQL.exportSelectedVariantAnalysisResults":
310313
this.exportSelectedVariantAnalysisResults.bind(this),
@@ -920,21 +923,14 @@ export class QueryHistoryManager extends DisposableObject {
920923
);
921924
}
922925

923-
async handleCopyRepoList(
924-
singleItem: QueryHistoryInfo,
925-
multiSelect: QueryHistoryInfo[] | undefined,
926-
) {
927-
// Variant analyses only
928-
if (
929-
!this.assertSingleQuery(multiSelect) ||
930-
singleItem.t !== "variant-analysis"
931-
) {
926+
async handleCopyRepoList(item: QueryHistoryInfo) {
927+
if (item.t !== "variant-analysis") {
932928
return;
933929
}
934930

935931
await this.app.commands.execute(
936932
"codeQL.copyVariantAnalysisRepoList",
937-
singleItem.variantAnalysis.id,
933+
item.variantAnalysis.id,
938934
);
939935
}
940936

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ describe("QueryHistoryManager", () => {
704704
queryHistoryManager = await createMockQueryHistory(localQueryHistory);
705705

706706
const item = localQueryHistory[4];
707-
await queryHistoryManager.handleCopyRepoList(item, [item]);
707+
await queryHistoryManager.handleCopyRepoList(item);
708708

709709
expect(executeCommand).not.toBeCalled();
710710
});
@@ -713,21 +713,12 @@ describe("QueryHistoryManager", () => {
713713
queryHistoryManager = await createMockQueryHistory(allHistory);
714714

715715
const item = variantAnalysisHistory[1];
716-
await queryHistoryManager.handleCopyRepoList(item, [item]);
716+
await queryHistoryManager.handleCopyRepoList(item);
717717
expect(executeCommand).toBeCalledWith(
718718
"codeQL.copyVariantAnalysisRepoList",
719719
item.variantAnalysis.id,
720720
);
721721
});
722-
723-
it("should not copy repo list for multiple variant analyses", async () => {
724-
queryHistoryManager = await createMockQueryHistory(allHistory);
725-
726-
const item1 = variantAnalysisHistory[1];
727-
const item2 = variantAnalysisHistory[3];
728-
await queryHistoryManager.handleCopyRepoList(item1, [item1, item2]);
729-
expect(executeCommand).not.toBeCalled();
730-
});
731722
});
732723

733724
describe("handleExportResults", () => {

0 commit comments

Comments
 (0)