Skip to main content

undo

Function undo 

pub fn undo(
    doc: &mut AutoCommit,
    scope: &Scope,
    limit: usize,
    compensate: impl FnMut(&Version) -> Result<Option<Box<dyn Action>>, String>,
    words: &dyn HistoryWords,
) -> Result<Vec<Version>, String>
Expand description

Take back scope’s last limit steps that are in effect, as one new change in doc’s open transaction: each through the inverse compensate gives for it, else by reverting its patches. Returns the steps, newest first. On a refusal some of it may already be written: the caller discards the transaction, as the action executor does for a refused action.

§Errors

Says why nothing was undone, in words: there is nothing of the scope’s to undo, or an inverse cannot be applied. What somebody else changed since is never a reason: their newer value stays and the step is undone.