SaveUndoStart saves the current state -- call if MustSaveUndoStart is true. Sets a special flag for this record, and action, data are empty. Does NOT increment the index, so next undo is still as expected.
(state []string)
| 161 | // Sets a special flag for this record, and action, data are empty. |
| 162 | // Does NOT increment the index, so next undo is still as expected. |
| 163 | func (us *Stack) SaveUndoStart(state []string) { |
| 164 | us.Mu.Lock() |
| 165 | nr := &Record{UndoSave: true} |
| 166 | us.Records = append(us.Records, nr) |
| 167 | us.SaveState(nr, us.Index+1, state) // do it now because we need to immediately do Undo, does unlock |
| 168 | } |
| 169 | |
| 170 | // SaveReplace replaces the current Undo record with new state, |
| 171 | // instead of creating a new record. This is useful for when |