Add undo system with coalescing logic and comprehensive tests.
- Implemented robust undo system supporting coalescing of text operations (insert, backspace, delete). - Added `UndoSystem` integration into the editor/commands pipeline. - Wrote extensive unit tests for various undo/redo scenarios, including multiline operations, cursor preservation, and history management. - Refactored to ensure consistent cursor behavior during undo/redo actions. - Updated CMake to include new tests.
This commit is contained in:
@@ -33,6 +33,11 @@ public:
|
||||
void UpdateBufferReference(Buffer &new_buf);
|
||||
|
||||
private:
|
||||
enum class PendingAppendMode : std::uint8_t {
|
||||
Append,
|
||||
Prepend,
|
||||
};
|
||||
|
||||
void apply(const UndoNode *node, int direction); // +1 redo, -1 undo
|
||||
void free_node(UndoNode *node);
|
||||
|
||||
@@ -48,6 +53,8 @@ private:
|
||||
|
||||
void update_dirty_flag();
|
||||
|
||||
PendingAppendMode pending_mode_ = PendingAppendMode::Append;
|
||||
|
||||
Buffer *buf_;
|
||||
UndoTree &tree_;
|
||||
};
|
||||
Reference in New Issue
Block a user