Skip to content

Commit 686d874

Browse files
Merge pull request #2384 from github/robertbrignull/makeSelected
Fix not setting database as selected if it already exists
2 parents 39b890d + b786b56 commit 686d874

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Fix bug where the "CodeQL: Set Current Database" command didn't always select the database. [#2384](https://github.com/github/vscode-codeql/pull/2384)
6+
57
## 1.8.3 - 26 April 2023
68

79
- Added ability to filter repositories for a variant analysis to only those that have results [#2343](https://github.com/github/vscode-codeql/pull/2343)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ export class DatabaseManager extends DisposableObject {
621621
progress: ProgressCallback,
622622
token: vscode.CancellationToken,
623623
uri: vscode.Uri,
624-
makeSelected = false,
624+
makeSelected = true,
625625
displayName?: string,
626626
isTutorialDatabase?: boolean,
627627
): Promise<DatabaseItem> {
@@ -645,12 +645,15 @@ export class DatabaseManager extends DisposableObject {
645645
public async addExistingDatabaseItem(
646646
databaseItem: DatabaseItem,
647647
progress: ProgressCallback,
648-
makeSelected = true,
648+
makeSelected: boolean,
649649
token: vscode.CancellationToken,
650650
isTutorialDatabase?: boolean,
651651
): Promise<DatabaseItem> {
652652
const existingItem = this.findDatabaseItem(databaseItem.databaseUri);
653653
if (existingItem !== undefined) {
654+
if (makeSelected) {
655+
await this.setCurrentDatabaseItem(existingItem);
656+
}
654657
return existingItem;
655658
}
656659

extensions/ql-vscode/src/test-runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export class TestRunner extends DisposableObject {
112112
},
113113
token,
114114
uri,
115+
false,
115116
);
116117
await this.databaseManager.renameDatabaseItem(
117118
reopenedDatabase,

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-databases.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,17 +749,14 @@ describe("local databases", () => {
749749
mockDbItem.databaseUri,
750750
);
751751

752-
expect(resolveDatabaseContentsSpy).toBeCalledTimes(1);
752+
expect(resolveDatabaseContentsSpy).toBeCalledTimes(2);
753753
});
754754

755755
it("should set the database as the currently selected one", async () => {
756-
const makeSelected = true;
757-
758756
await databaseManager.openDatabase(
759757
{} as ProgressCallback,
760758
{} as CancellationToken,
761759
mockDbItem.databaseUri,
762-
makeSelected,
763760
);
764761

765762
expect(setCurrentDatabaseItemSpy).toBeCalledTimes(1);

extensions/ql-vscode/test/vscode-tests/no-workspace/test-runner.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ describe("test-runner", () => {
172172
expect.anything(),
173173
expect.anything(),
174174
preTestDatabaseItem.databaseUri,
175+
false,
175176
);
176177

177178
expect(renameDatabaseItemSpy).toBeCalledTimes(1);

0 commit comments

Comments
 (0)