Implement branching undo system with tests and updates.
- Added branching model for undo/redo, enabling multiple redo paths and branch selection. - Updated `UndoNode` to include `parent` and refined hierarchical navigation. - Extended `UndoSystem` with branching logic for redo operations, supporting sibling branch selection. - Overhauled tests to validate branching behavior and tree invariants. - Refined editor command logic for undo/redo with repeat counts and branch selection. - Enabled test-only introspection hooks for undo tree validation. - Updated CMake to include test definitions (`KTE_TESTS` flag).
This commit is contained in:
13
UndoSystem.h
13
UndoSystem.h
@@ -22,7 +22,10 @@ public:
|
||||
|
||||
void undo();
|
||||
|
||||
void redo();
|
||||
// Redo the current node's active child branch.
|
||||
// If `branch_index` > 0, selects that redo sibling (0-based) and makes it active.
|
||||
// When current is null (pre-first-edit), branches are selected among `tree_.root` siblings.
|
||||
void redo(int branch_index = 0);
|
||||
|
||||
void mark_saved();
|
||||
|
||||
@@ -32,6 +35,14 @@ public:
|
||||
|
||||
void UpdateBufferReference(Buffer &new_buf);
|
||||
|
||||
#if defined(KTE_TESTS)
|
||||
// Test-only introspection hook.
|
||||
const UndoTree &TreeForTests() const
|
||||
{
|
||||
return tree_;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
enum class PendingAppendMode : std::uint8_t {
|
||||
Append,
|
||||
|
||||
Reference in New Issue
Block a user