//editor/com.aardarch.aardink.core/EditorUndoManager
EditorUndoManager
class EditorUndoManager(maxOperations: Int = 200)
Operation-log undo/redo manager.
Stores EditOperation records instead of full-text snapshots, capping memory at O(operations) rather than O(operations × document_size).
Consecutive single-character insertions at adjacent offsets are merged into one batch (matching the heuristic VS Code uses: batch until a word boundary or non-contiguous edit is detected).
Constructors
| EditorUndoManager | constructor(maxOperations: Int = 200) |
Types
| Name | Summary |
|---|---|
| EditOperation | sealed class EditOperation |
Properties
| Name | Summary |
|---|---|
| canRedo | val canRedo: Boolean |
| canUndo | val canUndo: Boolean |
Functions
| Name | Summary |
|---|---|
| clear | fun clear() |
| flushPendingInsert | fun flushPendingInsert() Commits any pending batched insert to the undo stack. Call before any non-insert operation. |
| inverseOf | fun inverseOf(op: EditorUndoManager.EditOperation): EditorUndoManager.EditOperation Returns the inverse of op — i.e. the operation that should be applied to the document when undoing op. |
| recordBatch | fun recordBatch(operations: List<EditorUndoManager.EditOperation>) Records multiple operations as a single undoable batch (e.g. format-on-save, paste). |
| recordDelete | fun recordDelete(offset: Int, length: Int, deletedText: String) Records that length characters (deletedText) were deleted starting at offset. |
| recordInsert | fun recordInsert(offset: Int, text: String) Records that text was inserted at offset. Single-character insertions at adjacent positions are batched together. |
| redo | fun redo(): EditorUndoManager.EditOperation? Returns the operation to re-apply (and records it back on the undo stack), or null. |
| undo | fun undo(): EditorUndoManager.EditOperation? Returns the operation to reverse (and records its inverse on the redo stack), or null if there is nothing to undo. |