Skip to content

Commit 890549f

Browse files
committed
Fix database selection
1 parent 66825d6 commit 890549f

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
Uri,
1111
window as Window,
1212
env,
13-
window
13+
window,
14+
QuickPickItem
1415
} from 'vscode';
1516
import { LanguageClient } from 'vscode-languageclient';
1617
import * as os from 'os';
@@ -559,6 +560,9 @@ async function activateWithInstalledDistribution(
559560
}
560561
)
561562
);
563+
interface DatabaseQuickPickItem extends QuickPickItem {
564+
databaseItem: DatabaseItem;
565+
}
562566
ctx.subscriptions.push(
563567
commandRunnerWithProgress(
564568
'codeQL.runQueryOnMultipleDatabases',
@@ -567,20 +571,23 @@ async function activateWithInstalledDistribution(
567571
token: CancellationToken,
568572
uri: Uri | undefined
569573
) => {
574+
const quickPickItems = dbm.databaseItems.map<DatabaseQuickPickItem>(dbItem => (
575+
{
576+
databaseItem: dbItem,
577+
label: dbItem.name,
578+
description: dbItem.language,
579+
}
580+
));
570581
/**
571-
* Databases selected from the quick pick menu.
582+
* Databases that were selected in the quick pick menu.
572583
*/
573-
const quickpick = await window.showQuickPick(
574-
// TODO: Return items of type "DatabaseItem" instead of "string"
575-
// For this to work, I think we need "DatabaseItem" to extend "QuickPickItem":
576-
// https://code.visualstudio.com/api/references/vscode-api#QuickPickItem
577-
dbm.databaseItems.map(dbItem => dbItem.name),
578-
{ canPickMany: true },
584+
const quickpick = await window.showQuickPick<DatabaseQuickPickItem>(
585+
quickPickItems,
586+
{ canPickMany: true }
579587
);
580588
if (quickpick !== undefined) {
581589
for (const item of quickpick) {
582-
// Instead of "item" (which is a string), we need the associated "DatabaseItem"...
583-
await compileAndRunQuery(false, uri, progress, token, item);
590+
await compileAndRunQuery(false, uri, progress, token, item.databaseItem);
584591
}
585592
} else {
586593
void helpers.showAndLogErrorMessage('No databases selected.');

0 commit comments

Comments
 (0)