MCPcopy Create free account
hub / github.com/cogentcore/core / Undo

Method Undo

undo/undo.go:215–228  ·  view source on GitHub ↗

Undo returns the action, action data, and state at the current index and decrements the index to the previous record. This state is the state just prior to the action. If already at the start (Index = -1) then returns empty everything Before calling, first check MustSaveUndoStart() -- if false, then

()

Source from the content-addressed store, hash-verified

213// Before calling, first check MustSaveUndoStart() -- if false, then you need
214// to call SaveUndoStart() so that the state just before Undoing can be redone!
215func (us *Stack) Undo() (action, data string, state []string) {
216 us.Mu.Lock()
217 if us.Index < 0 || us.Index >= len(us.Records) {
218 us.Mu.Unlock()
219 return
220 }
221 rec := us.Records[us.Index]
222 action = rec.Action
223 data = rec.Data
224 state = us.RecState(us.Index)
225 us.Index--
226 us.Mu.Unlock()
227 return
228}
229
230// UndoTo returns the action, action data, and state at the given index
231// and decrements the index to the previous record.

Callers

nothing calls this directly

Calls 3

RecStateMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected