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

Method RecState

undo/undo.go:92–110  ·  view source on GitHub ↗

RecState returns the state for given index, reconstructing from diffs as needed. Must be called under lock.

(idx int)

Source from the content-addressed store, hash-verified

90// RecState returns the state for given index, reconstructing from diffs
91// as needed. Must be called under lock.
92func (us *Stack) RecState(idx int) []string {
93 stidx := 0
94 var cdt []string
95 for i := idx; i >= 0; i-- {
96 r := us.Records[i]
97 if r.Raw != nil {
98 stidx = i
99 cdt = r.Raw
100 break
101 }
102 }
103 for i := stidx + 1; i <= idx; i++ {
104 r := us.Records[i]
105 if r.Patch != nil {
106 cdt = r.Patch.Apply(cdt)
107 }
108 }
109 return cdt
110}
111
112// Save saves a new action as next action to be undone, with given action
113// data and current full state of the system (either of which are optional).

Callers 5

SaveStateMethod · 0.95
UndoMethod · 0.95
UndoToMethod · 0.95
RedoMethod · 0.95
RedoToMethod · 0.95

Calls 1

ApplyMethod · 0.65

Tested by

no test coverage detected