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:
2026-02-10 23:13:00 -08:00
parent 1c0f04f076
commit cc8df36bdf
7 changed files with 689 additions and 57 deletions

View File

@@ -20,10 +20,11 @@ public:
available_.pop();
// Node comes zeroed; ensure links are reset
node->text.clear();
node->child = nullptr;
node->next = nullptr;
node->row = node->col = 0;
node->type = UndoType{};
node->parent = nullptr;
node->child = nullptr;
node->next = nullptr;
node->row = node->col = 0;
node->type = UndoType{};
return node;
}
@@ -34,10 +35,11 @@ public:
return;
// Clear heavy fields to free memory held by strings
node->text.clear();
node->child = nullptr;
node->next = nullptr;
node->row = node->col = 0;
node->type = UndoType{};
node->parent = nullptr;
node->child = nullptr;
node->next = nullptr;
node->row = node->col = 0;
node->type = UndoType{};
available_.push(node);
}