Appearance
History
Undo / redo of committed history entries. History steps operate on Snaptrude's command stack: undo steps back over committed entries, redo re-applies undone ones. Both take an optional step count (default 1) and report how many steps were actually applied — fewer than requested when the stack runs out. Accessed via snaptrude.core.history.
Types
PluginHistoryStepArgs
Arguments for undo / redo.
| Property | Type | Description |
|---|---|---|
steps | number (optional, default 1) | Number of history entries to step (positive integer). |
PluginHistoryStepResult
Result of undo / redo.
| Property | Type | Description |
|---|---|---|
stepsApplied | number | History entries actually stepped — ≤ steps, fewer when the stack ran out. |
Functions
undo(steps?)
Step back over committed history entries.
- Parameters:
steps:number(optional, default1) — The number of entries to undo.
- Returns:
PluginHistoryStepResult—stepsAppliedis the entries actually undone (≤steps; fewer if the undo stack ran out).
ts
await snaptrude.core.history.undo(); // one step
await snaptrude.core.history.undo(3); // up to three stepsredo(steps?)
Step forward over previously undone entries. Symmetric with undo.
- Parameters:
steps:number(optional, default1) — The number of entries to redo.
- Returns:
PluginHistoryStepResult—stepsAppliedis the entries actually redone (≤steps; fewer if the redo stack ran out).
ts
await snaptrude.core.history.redo();
await snaptrude.core.history.redo(2);Errors
Failed calls reject with a typed PluginError — see Error Handling. This namespace has no specific error conditions: an exhausted stack or a blocked entry is never an error — the loop stops early and the shortfall shows up as a smaller stepsApplied.