diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 83a94ffc7d2..91af62b3651 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -3461,7 +3461,7 @@ export class CommandCenter { */ this.telemetryReporter.sendTelemetryEvent('git.command', { command: id }); - return result.catch(async err => { + return result.catch(err => { const options: MessageOptions = { modal: true }; @@ -3559,26 +3559,10 @@ export class CommandCenter { return; } - let result: string | undefined; - const allChoices = Array.from(choices.keys()); - - switch (type) { - case 'error': - result = await window.showErrorMessage(message, options, ...allChoices); - break; - case 'warning': - result = await window.showWarningMessage(message, options, ...allChoices); - break; - case 'information': - result = await window.showInformationMessage(message, options, ...allChoices); - break; - } - - if (result) { - const resultFn = choices.get(result); - - resultFn?.(); - } + // We explicitly do not await this promise, because we do not + // want the command execution to be stuck waiting for the user + // to take action on the notification. + this.showErrorNotification(type, message, options, choices); }); }; @@ -3588,6 +3572,29 @@ export class CommandCenter { return result; } + private async showErrorNotification(type: 'error' | 'warning' | 'information', message: string, options: MessageOptions, choices: Map void>): Promise { + let result: string | undefined; + const allChoices = Array.from(choices.keys()); + + switch (type) { + case 'error': + result = await window.showErrorMessage(message, options, ...allChoices); + break; + case 'warning': + result = await window.showWarningMessage(message, options, ...allChoices); + break; + case 'information': + result = await window.showInformationMessage(message, options, ...allChoices); + break; + } + + if (result) { + const resultFn = choices.get(result); + + resultFn?.(); + } + } + private getSCMResource(uri?: Uri): Resource | undefined { uri = uri ? uri : (window.activeTextEditor && window.activeTextEditor.document.uri);