Skip to content

Commit b91524a

Browse files
committed
Don't create undo history item for a paste that does nothing.
1 parent 1a25590 commit b91524a

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,20 @@ public int CopyOverInput(int frame, IEnumerable<IController> inputStates)
237237
Log[frame + i] = entry;
238238
}
239239

240-
ChangeLog.EndBatch();
241-
Changes = true;
242240
if (firstChangedFrame != -1)
243241
{
244-
// TODO: Throw out the undo action if there are no changes.
242+
ChangeLog.EndBatch();
243+
Changes = true;
244+
245245
InvalidateAfter(firstChangedFrame);
246+
247+
ChangeLog.SetGeneralRedo();
248+
}
249+
else
250+
{
251+
ChangeLog.AbortBatch();
246252
}
247253

248-
ChangeLog.SetGeneralRedo();
249254
return firstChangedFrame;
250255
}
251256

src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public interface IMovieChangeLog
1111
bool IsRecording { get; set; }
1212
void Clear(int upTo = -1);
1313
bool BeginNewBatch(string name = "", bool keepOldBatch = false);
14+
void AbortBatch();
1415
void EndBatch();
1516
int Undo();
1617
int Redo();
@@ -146,6 +147,16 @@ public bool BeginNewBatch(string name = "", bool keepOldBatch = false)
146147
return ret;
147148
}
148149

150+
/// <summary>
151+
/// Ends the current undo batch and deletes any undo actions it contains.
152+
/// </summary>
153+
public void AbortBatch()
154+
{
155+
_history.RemoveAt(_history.Count - 1);
156+
Names.RemoveAt(Names.Count - 1);
157+
UndoIndex--;
158+
}
159+
149160
/// <summary>
150161
/// Ends the current undo batch. Future changes will be one undo each.
151162
/// If not already recording a batch, does nothing.
@@ -161,9 +172,7 @@ public void EndBatch()
161172
var last = LatestBatch;
162173
if (last.Count == 0) // Remove batch if it's empty.
163174
{
164-
_history.RemoveAt(_history.Count - 1);
165-
Names.RemoveAt(Names.Count - 1);
166-
UndoIndex--;
175+
AbortBatch();
167176
}
168177
else
169178
{

0 commit comments

Comments
 (0)