@@ -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