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

Method UndoTo

undo/undo.go:233–246  ·  view source on GitHub ↗

UndoTo returns the action, action data, and state at the given index and decrements the index to the previous record. If idx is out of range then returns empty everything

(idx int)

Source from the content-addressed store, hash-verified

231// and decrements the index to the previous record.
232// If idx is out of range then returns empty everything
233func (us *Stack) UndoTo(idx int) (action, data string, state []string) {
234 us.Mu.Lock()
235 if idx < 0 || idx >= len(us.Records) {
236 us.Mu.Unlock()
237 return
238 }
239 rec := us.Records[idx]
240 action = rec.Action
241 data = rec.Data
242 state = us.RecState(idx)
243 us.Index = idx - 1
244 us.Mu.Unlock()
245 return
246}
247
248// Redo returns the action, data at the *next* index, and the state at the
249// index *after that*.

Callers

nothing calls this directly

Calls 3

RecStateMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected