Git - mark a failed operation completed as soon as the error dialog is shown (#172509)

This commit is contained in:
Ladislau Szomoru
2023-01-30 09:57:09 +01:00
committed by GitHub
parent e130330102
commit 1c2d4e6c6c

View File

@@ -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<string, () => void>): Promise<void> {
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);