Merge pull request #2384 from github/robertbrignull/makeSelected

Fix not setting database as selected if it already exists
This commit is contained in:
Robert
2023-04-27 17:19:01 +01:00
committed by GitHub
5 changed files with 10 additions and 6 deletions

View File

@@ -2,6 +2,8 @@
## [UNRELEASED]
- Fix bug where the "CodeQL: Set Current Database" command didn't always select the database. [#2384](https://github.com/github/vscode-codeql/pull/2384)
## 1.8.3 - 26 April 2023
- Added ability to filter repositories for a variant analysis to only those that have results [#2343](https://github.com/github/vscode-codeql/pull/2343)

View File

@@ -621,7 +621,7 @@ export class DatabaseManager extends DisposableObject {
progress: ProgressCallback,
token: vscode.CancellationToken,
uri: vscode.Uri,
makeSelected = false,
makeSelected = true,
displayName?: string,
isTutorialDatabase?: boolean,
): Promise<DatabaseItem> {
@@ -645,12 +645,15 @@ export class DatabaseManager extends DisposableObject {
public async addExistingDatabaseItem(
databaseItem: DatabaseItem,
progress: ProgressCallback,
makeSelected = true,
makeSelected: boolean,
token: vscode.CancellationToken,
isTutorialDatabase?: boolean,
): Promise<DatabaseItem> {
const existingItem = this.findDatabaseItem(databaseItem.databaseUri);
if (existingItem !== undefined) {
if (makeSelected) {
await this.setCurrentDatabaseItem(existingItem);
}
return existingItem;
}

View File

@@ -112,6 +112,7 @@ export class TestRunner extends DisposableObject {
},
token,
uri,
false,
);
await this.databaseManager.renameDatabaseItem(
reopenedDatabase,

View File

@@ -749,17 +749,14 @@ describe("local databases", () => {
mockDbItem.databaseUri,
);
expect(resolveDatabaseContentsSpy).toBeCalledTimes(1);
expect(resolveDatabaseContentsSpy).toBeCalledTimes(2);
});
it("should set the database as the currently selected one", async () => {
const makeSelected = true;
await databaseManager.openDatabase(
{} as ProgressCallback,
{} as CancellationToken,
mockDbItem.databaseUri,
makeSelected,
);
expect(setCurrentDatabaseItemSpy).toBeCalledTimes(1);

View File

@@ -172,6 +172,7 @@ describe("test-runner", () => {
expect.anything(),
expect.anything(),
preTestDatabaseItem.databaseUri,
false,
);
expect(renameDatabaseItemSpy).toBeCalledTimes(1);