Skip to content

Commit 8414415

Browse files
committed
Add "Show log" button for all messages
This change ensures that "Show log" is available on all messages from the extension. It's important to note that the only place that was specifying an "item" before was doing it incorrectly. That's been fixed. Closes #287
1 parent 059a75c commit 8414415

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

extensions/ql-vscode/src/databases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ export class DatabaseManager extends DisposableObject {
571571
}
572572
} catch (e) {
573573
// database list had an unexpected type - nothing to be done?
574-
showAndLogErrorMessage('Database list loading failed: ${}', e.message);
574+
showAndLogErrorMessage(`Database list loading failed: ${e.message}`);
575575
}
576576
}
577577

extensions/ql-vscode/src/helpers.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ export function withProgress<R>(
5151
*
5252
* @return A thenable that resolves to the selected item or undefined when being dismissed.
5353
*/
54-
export function showAndLogErrorMessage(message: string, ...items: string[]): Thenable<string | undefined> {
55-
logger.log(message);
56-
return Window.showErrorMessage(message, ...items);
54+
export async function showAndLogErrorMessage(message: string, ...items: string[]): Promise<string | undefined> {
55+
return internalShowAndLog(message, Window.showErrorMessage, ...items);
5756
}
5857
/**
5958
* Show a warning message and log it to the console
@@ -63,9 +62,8 @@ export function showAndLogErrorMessage(message: string, ...items: string[]): The
6362
*
6463
* @return A thenable that resolves to the selected item or undefined when being dismissed.
6564
*/
66-
export function showAndLogWarningMessage(message: string, ...items: string[]): Thenable<string | undefined> {
67-
logger.log(message);
68-
return Window.showWarningMessage(message, ...items);
65+
export async function showAndLogWarningMessage(message: string, ...items: string[]): Promise<string | undefined> {
66+
return internalShowAndLog(message, Window.showWarningMessage, ...items);
6967
}
7068
/**
7169
* Show an information message and log it to the console
@@ -75,9 +73,18 @@ export function showAndLogWarningMessage(message: string, ...items: string[]): T
7573
*
7674
* @return A thenable that resolves to the selected item or undefined when being dismissed.
7775
*/
78-
export function showAndLogInformationMessage(message: string, ...items: string[]): Thenable<string | undefined> {
76+
export async function showAndLogInformationMessage(message: string, ...items: string[]): Promise<string | undefined> {
77+
return internalShowAndLog(message, Window.showInformationMessage, ...items);
78+
}
79+
80+
async function internalShowAndLog(message: string, fn: Function, ...items: string[]): Promise<string | undefined> {
7981
logger.log(message);
80-
return Window.showInformationMessage(message, ...items);
82+
const label = 'Show log';
83+
const result = await fn(message, label, ...items);
84+
if (result === label) {
85+
logger.show();
86+
}
87+
return result;
8188
}
8289

8390
/**

0 commit comments

Comments
 (0)