refactor(editor): the open sequence's jobs in their own type; restore undo as an object
WIP of the interrupted fix stage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
9 files changed
+356
-42
No files matched your search
@@ -48,9 +48,9 @@ public sealed class SavedCopiesTests(TestContext context)
|
||||
session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.6 } });
|
||||
var edited = session.Project;
|
||||
|
||||
Assert.True(await session.RestoreAsync(copy));
|
||||
Assert.NotNull(await session.RestoreAsync(copy));
|
||||
Assert.True(ProjectMerge.SameValues(kept, session.Project));
|
||||
Assert.False(await session.RestoreAsync(copy), "the same values again change nothing");
|
||||
Assert.Null(await session.RestoreAsync(copy), "the same values again change nothing");
|
||||
await session.FlushAsync();
|
||||
Assert.True(ProjectMerge.SameValues(kept, source.Stored), "the restored project is saved");
|
||||
|
||||
@@ -59,4 +59,33 @@ public sealed class SavedCopiesTests(TestContext context)
|
||||
Assert.True(session.Undo());
|
||||
Assert.True(ProjectMerge.SameValues(before, session.Project));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheUndoOfARestoreTakesBackOnlyTheRestore()
|
||||
{
|
||||
var meta = context.CreateTempDirectory("meta");
|
||||
var path = Path.Combine(meta, "project.this-pc-20261003-142200.json");
|
||||
File.WriteAllText(path, new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = -0.3 } }.ToJson());
|
||||
var copy = Assert.Contains(SavedCopies.List(meta), _ => true);
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
await using var session = new EditorSession(new FakeSequenceSource(EditorFixture.Sunset, content), content, [], TimeSpan.FromMilliseconds(20));
|
||||
session.Edit(p => p with { HeroFrame = 4 });
|
||||
var before = session.Project;
|
||||
|
||||
var restore = Assert.NotNull(await session.RestoreAsync(copy));
|
||||
Assert.True(restore.CanUndo);
|
||||
Assert.True(restore.Undo());
|
||||
Assert.True(ProjectMerge.SameValues(before, session.Project), "the project from before the restore");
|
||||
Assert.False(restore.CanUndo, "taken back once");
|
||||
Assert.True(session.Undo(), "the undo of the restore is a step of its own");
|
||||
Assert.Equal(-0.3, session.Project.Exposure.ExposureOffsetEv);
|
||||
|
||||
// An edit after the restore: its Undo would take that edit back, so it no longer applies.
|
||||
session.Edit(p => p with { HeroFrame = 5 });
|
||||
restore = Assert.NotNull(await session.RestoreAsync(copy));
|
||||
session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.9 } });
|
||||
Assert.False(restore.CanUndo);
|
||||
Assert.False(restore.Undo());
|
||||
Assert.Equal(0.9, session.Project.Exposure.ExposureOffsetEv);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user