Skip to content

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.

PropertyTypeDescription
stepsnumber (optional, default 1)Number of history entries to step (positive integer).

PluginHistoryStepResult

Result of undo / redo.

PropertyTypeDescription
stepsAppliednumberHistory entries actually stepped — ≤ steps, fewer when the stack ran out.

Functions

undo(steps?)

Step back over committed history entries.

  • Parameters:
    • steps: number (optional, default 1) — The number of entries to undo.
  • Returns: PluginHistoryStepResultstepsApplied is 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 steps

redo(steps?)

Step forward over previously undone entries. Symmetric with undo.

  • Parameters:
    • steps: number (optional, default 1) — The number of entries to redo.
  • Returns: PluginHistoryStepResultstepsApplied is 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.