Skip to content

Commit d56f51b

Browse files
committed
Truncate long database upgrade messages in native dialog box.
1 parent 20c312e commit d56f51b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

extensions/ql-vscode/src/queries.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import { promisify } from 'util';
1515
import { QueryHistoryItemOptions } from './query-history';
1616
import { isQuickQueryPath } from './quick-query';
1717

18+
/**
19+
* Maximum number of lines to put in a binary choice dialog message,
20+
* to work around the fact that we can't guarantee a scrollable text
21+
* box for it.
22+
*/
23+
const MAX_MESSAGE_LINES = 20;
24+
1825
/**
1926
* queries.ts
2027
* -------------
@@ -273,7 +280,13 @@ async function checkAndConfirmDatabaseUpgrade(qs: qsClient.QueryServerClient, db
273280

274281
logger.log(descriptionMessage);
275282
// Ask the user to confirm the upgrade.
276-
const shouldUpgrade = await helpers.showBinaryChoiceDialog(`Should the database ${db.databaseUri.fsPath} be upgraded?\n\n${descriptionMessage}`);
283+
284+
let messageLines = descriptionMessage.split('\n');
285+
if (messageLines.length > MAX_MESSAGE_LINES) {
286+
messageLines = messageLines.slice(0, MAX_MESSAGE_LINES);
287+
messageLines.push("... [full list of changes can be found in Output > CodeQL Extension Log]");
288+
}
289+
const shouldUpgrade = await helpers.showBinaryChoiceDialog(`Should the database ${db.databaseUri.fsPath} be upgraded?\n\n${messageLines.join("\n")}`);
277290
if (shouldUpgrade) {
278291
return params;
279292
}

0 commit comments

Comments
 (0)