← API reference

//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

EditorUndoManagerconstructor(maxOperations: Int = 200)

Types

NameSummary
EditOperationsealed class EditOperation

Properties

NameSummary
canRedoval canRedo: Boolean
canUndoval canUndo: Boolean

Functions

NameSummary
clearfun clear()
flushPendingInsertfun flushPendingInsert()
Commits any pending batched insert to the undo stack. Call before any non-insert operation.
inverseOffun 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.
recordBatchfun recordBatch(operations: List<EditorUndoManager.EditOperation>)
Records multiple operations as a single undoable batch (e.g. format-on-save, paste).
recordDeletefun recordDelete(offset: Int, length: Int, deletedText: String)
Records that length characters (deletedText) were deleted starting at offset.
recordInsertfun recordInsert(offset: Int, text: String)
Records that text was inserted at offset. Single-character insertions at adjacent positions are batched together.
redofun redo(): EditorUndoManager.EditOperation?
Returns the operation to re-apply (and records it back on the undo stack), or null.
undofun undo(): EditorUndoManager.EditOperation?
Returns the operation to reverse (and records its inverse on the redo stack), or null if there is nothing to undo.