Skip to content

EditHistory

Namespace: Hex1b.Documents

Assembly: Hex1b.dll

Manages undo/redo history for an editor. Supports explicit grouping, automatic typing coalescing, and cursor state restoration.

csharp
public sealed class EditHistory

Inheritance

ObjectEditHistory

Properties

CanRedo

Whether there are operations to redo.

Returns: Boolean

csharp
public bool CanRedo { get; }

CanUndo

Whether there are operations to undo.

Returns: Boolean

csharp
public bool CanUndo { get; }

CoalesceTimeoutMs

Maximum time in milliseconds between keystrokes for typing coalescing.

Returns: Int64

csharp
public long CoalesceTimeoutMs { get; set; }

RedoCount

Number of redo groups on the stack.

Returns: Int32

csharp
public int RedoCount { get; }

UndoCount

Number of undo groups on the stack.

Returns: Int32

csharp
public int UndoCount { get; }

Methods

BeginGroup(CursorSet, long, string?)

Begin a new explicit edit group. Nested calls increment a counter; only the outermost Commit actually pushes the group.

Parameters:

csharp
public void BeginGroup(CursorSet cursors, long documentVersion, string? source = null)

CancelGroup()

Cancel the current edit group. Drops all collected operations. The caller is responsible for reverting the document state.

csharp
public void CancelGroup()

Clear()

Clear all history.

csharp
public void Clear()

CommitGroup(CursorSet, long)

Commit the current edit group. Only the outermost commit pushes to undo stack.

Parameters:

csharp
public void CommitGroup(CursorSet cursors, long documentVersion)

RecordEdit(EditOperation, EditOperation, CursorSet, long, long, bool)

Record an edit for potential coalescing with adjacent typing edits. If the edit can be coalesced with the previous group, it is appended. Otherwise, a new group is created.

Parameters:

csharp
public void RecordEdit(EditOperation operation, EditOperation inverse, CursorSet cursors, long versionBefore, long versionAfter, bool coalescable = false)

Redo()

Redo the last undone edit group. Returns the group for the caller to re-apply operations and restore cursors.

Returns: EditGroup

csharp
public EditGroup? Redo()

Undo()

Undo the last edit group. Returns the group for the caller to apply inverse operations and restore cursors.

Returns: EditGroup

csharp
public EditGroup? Undo()

Released under the MIT License.