936
}
937
return false;
939
940
private async _confirmAndExecuteWorkspaceUndo(strResource: string, element: WorkspaceStackElement, editStackSnapshot: EditStackSnapshot, undoConfirmed: boolean): Promise<void> {
942
>
if (element.canSplit() && !this._isPartOfUndoGroup(element)) {
943
>
// this element can be split
944
>
945
>
enum UndoChoice {
946
>
All = 0,
947
>
This = 1,
948
>
Cancel = 2
949
>
}
950
>
951
>
const { result } = await this._dialogService.prompt<UndoChoice>({
952
>
type: Severity.Info,
953
>
message: nls.localize('confirmWorkspace', "Would you like to undo '{0}' across all files?", element.label),
954
>
buttons: [
955
>
{
956
>
label: nls.localize({ key: 'ok', comment: ['{0} denotes a number that is > 1, && denotes a mnemonic'] }, "&&Undo in {0} Files", editStackSnapshot.editStacks.length),
957
>
run: () => UndoChoice.All
958
>
},
959
>
{
960
>
label: nls.localize({ key: 'nok', comment: ['&& denotes a mnemonic'] }, "Undo this &&File"),
961
>
run: () => UndoChoice.This
962
>
}
963
>
],
964
>
cancelButton: {
965
>
run: () => UndoChoice.Cancel
966
>
}
967
>
});
968
>
969
>
if (result === UndoChoice.Cancel) {
970
// choice: cancel
971
return;
972
}
974
>
if (result === UndoChoice.This) {
975
// choice: undo this file
976
this._splitPastWorkspaceElement(element, null);
977
return this._undo(strResource, 0, true);
978
}
980
>
// choice: undo in all files
981
>
982
>
// At this point, it is possible that the element has been made invalid in the meantime (due to the confirmation await)
983
>
const verificationError1 = this._checkWorkspaceUndo(strResource, element, editStackSnapshot, /*invalidated resources will be checked after the prepare call*/false);
984
>
if (verificationError1) {
985
return verificationError1.returnValue;
986
}
988
>
undoConfirmed = true;
989
>
}
990
>
991
>
// prepare
992
>
let cleanup: IDisposable;
993
>
try {
994
>
cleanup = await this._invokeWorkspacePrepare(element);
995
>
} catch (err) {
996
return this._onError(err, element);
997
}
999
>
// At this point, it is possible that the element has been made invalid in the meantime (due to the prepare await)
1000
>
const verificationError2 = this._checkWorkspaceUndo(strResource, element, editStackSnapshot, /*now also check that there are no more invalidated resources*/true);
1001
>
if (verificationError2) {
1002
cleanup.dispose();
1003
return verificationError2.returnValue;
1004
}
1006
>
for (const editStack of editStackSnapshot.editStacks) {
1007
>
editStack.moveBackward(element);
1008
>
}
1009
>
return this._safeInvokeWithLocks(element, () => element.actual.undo(), editStackSnapshot, cleanup, () => this._continueUndoInGroup(element.groupId, undoConfirmed));
1010
>
}
1011
1012
private _resourceUndo(editStack: ResourceEditStack, element: ResourceStackElement, undoConfirmed: boolean): Promise<void> | void {