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

Method SaveState

undo/undo.go:183–193  ·  view source on GitHub ↗

SaveState saves given record of state at given index

(nr *Record, idx int, state []string)

Source from the content-addressed store, hash-verified

181
182// SaveState saves given record of state at given index
183func (us *Stack) SaveState(nr *Record, idx int, state []string) {
184 if idx%us.RawInterval == 0 {
185 nr.Raw = state
186 us.Mu.Unlock()
187 return
188 }
189 prv := us.RecState(idx - 1)
190 dif := text.DiffLines(prv, state)
191 nr.Patch = dif.ToPatch(state)
192 us.Mu.Unlock()
193}
194
195// HasUndoAvail returns true if there is at least one undo record available.
196// This does NOT get the lock -- may rarely be inaccurate but is used for

Callers 3

SaveMethod · 0.95
SaveUndoStartMethod · 0.95
SaveReplaceMethod · 0.95

Calls 4

RecStateMethod · 0.95
DiffLinesFunction · 0.92
ToPatchMethod · 0.80
UnlockMethod · 0.65

Tested by

no test coverage detected