Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ public async Task<ReturnResult> TryUndo()
{
return ReturnResult.InProgress;
}
bool keepHistory = false;
try
{
return await operations.Undo(App.HistoryWrapper.GetCurrentHistory());
ReturnResult result = await operations.Undo(App.HistoryWrapper.GetCurrentHistory());
keepHistory = result is ReturnResult.Cancelled;
return result;
}
finally
{
App.HistoryWrapper.DecreaseIndex();
if (!keepHistory)
App.HistoryWrapper.DecreaseIndex();

semaphore.Release();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public async Task<ReturnResult> Undo(IStorageHistory history)
case FileOperationType.CreateNew: // Opposite: Delete created items
if (!IsHistoryNull(history.Source))
{
return await helpers.DeleteItemsAsync(history.Source, false, true, false);
return await helpers.DeleteItemsAsync(history.Source, true, true, false); // Show a dialog to prevent unexpected deletion
}
break;
case FileOperationType.CreateLink: // Opposite: Delete created items
if (!IsHistoryNull(history.Destination))
{
return await helpers.DeleteItemsAsync(history.Destination, false, true, false);
return await helpers.DeleteItemsAsync(history.Destination, true, true, false); // Show a dialog to prevent unexpected deletion
}
break;
case FileOperationType.Rename: // Opposite: Restore original item names
Expand All @@ -61,7 +61,7 @@ public async Task<ReturnResult> Undo(IStorageHistory history)
case FileOperationType.Copy: // Opposite: Delete copied items
if (!IsHistoryNull(history.Destination))
{
return await helpers.DeleteItemsAsync(history.Destination, false, true, false);
return await helpers.DeleteItemsAsync(history.Destination, true, true, false); // Show a dialog to prevent unexpected deletion
}
break;
case FileOperationType.Move: // Opposite: Move the items to original directory
Expand Down