Browse Source

Fixed packet merging

flabbet 9 months ago
parent
commit
f226a2485a
1 changed files with 12 additions and 9 deletions
  1. 12 9
      src/PixiEditor.ChangeableDocument/DocumentChangeTracker.cs

+ 12 - 9
src/PixiEditor.ChangeableDocument/DocumentChangeTracker.cs

@@ -197,7 +197,8 @@ public class DocumentChangeTracker : IDisposable
         undoStack.Clear();
         undoStack.Clear();
     }
     }
 
 
-    private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessMakeChangeAction(IMakeChangeAction act)
+    private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessMakeChangeAction(IMakeChangeAction act,
+        ActionSource source)
     {
     {
         if (activeUpdateableChange is not null)
         if (activeUpdateableChange is not null)
         {
         {
@@ -216,13 +217,14 @@ public class DocumentChangeTracker : IDisposable
 
 
         var info = change.Apply(document, true, out bool ignoreInUndo);
         var info = change.Apply(document, true, out bool ignoreInUndo);
         if (!ignoreInUndo)
         if (!ignoreInUndo)
-            AddToUndo(change, ActionSource.User);
+            AddToUndo(change, source);
         else
         else
             change.Dispose();
             change.Dispose();
         return info;
         return info;
     }
     }
 
 
-    private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessStartOrUpdateChangeAction(IStartOrUpdateChangeAction act)
+    private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessStartOrUpdateChangeAction(IStartOrUpdateChangeAction act,
+        ActionSource source)
     {
     {
         if (activeUpdateableChange is null)
         if (activeUpdateableChange is null)
         {
         {
@@ -237,7 +239,7 @@ public class DocumentChangeTracker : IDisposable
             {
             {
                 var applyInfo = activeUpdateableChange.Apply(document, false, out bool ignoreInUndo);
                 var applyInfo = activeUpdateableChange.Apply(document, false, out bool ignoreInUndo);
                 if (!ignoreInUndo)
                 if (!ignoreInUndo)
-                    AddToUndo(activeUpdateableChange, ActionSource.User);
+                    AddToUndo(activeUpdateableChange, source);
                 else
                 else
                     activeUpdateableChange.Dispose();
                     activeUpdateableChange.Dispose();
 
 
@@ -287,7 +289,8 @@ public class DocumentChangeTracker : IDisposable
         return false;
         return false;
     }
     }
 
 
-    private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessEndChangeAction(IEndChangeAction act)
+    private OneOf<None, IChangeInfo, List<IChangeInfo>> ProcessEndChangeAction(IEndChangeAction act,
+        ActionSource source)
     {
     {
         if (activeUpdateableChange is null)
         if (activeUpdateableChange is null)
         {
         {
@@ -304,7 +307,7 @@ public class DocumentChangeTracker : IDisposable
 
 
         var info = activeUpdateableChange.Apply(document, true, out bool ignoreInUndo);
         var info = activeUpdateableChange.Apply(document, true, out bool ignoreInUndo);
         if (!ignoreInUndo)
         if (!ignoreInUndo)
-            AddToUndo(activeUpdateableChange, ActionSource.User);
+            AddToUndo(activeUpdateableChange, source);
         else
         else
             activeUpdateableChange.Dispose();
             activeUpdateableChange.Dispose();
         activeUpdateableChange = null;
         activeUpdateableChange = null;
@@ -326,13 +329,13 @@ public class DocumentChangeTracker : IDisposable
             switch (action.Item2)
             switch (action.Item2)
             {
             {
                 case IMakeChangeAction act:
                 case IMakeChangeAction act:
-                    AddInfo(ProcessMakeChangeAction(act));
+                    AddInfo(ProcessMakeChangeAction(act, action.Item1));
                     break;
                     break;
                 case IStartOrUpdateChangeAction act:
                 case IStartOrUpdateChangeAction act:
-                    AddInfo(ProcessStartOrUpdateChangeAction(act));
+                    AddInfo(ProcessStartOrUpdateChangeAction(act, action.Item1));
                     break;
                     break;
                 case IEndChangeAction act:
                 case IEndChangeAction act:
-                    AddInfo(ProcessEndChangeAction(act));
+                    AddInfo(ProcessEndChangeAction(act, action.Item1));
                     break;
                     break;
                 case Undo_Action:
                 case Undo_Action:
                     AddInfo(Undo());
                     AddInfo(Undo());