Redo returns the action, data at the *next* index, and the state at the index *after that*. returning nil if already at end of saved records.
()
| 249 | // index *after that*. |
| 250 | // returning nil if already at end of saved records. |
| 251 | func (us *Stack) Redo() (action, data string, state []string) { |
| 252 | us.Mu.Lock() |
| 253 | if us.Index >= len(us.Records)-2 { |
| 254 | us.Mu.Unlock() |
| 255 | return |
| 256 | } |
| 257 | us.Index++ |
| 258 | rec := us.Records[us.Index] // action being redone is this one |
| 259 | action = rec.Action |
| 260 | data = rec.Data |
| 261 | state = us.RecState(us.Index + 1) // state is the one *after* it |
| 262 | us.Mu.Unlock() |
| 263 | return |
| 264 | } |
| 265 | |
| 266 | // RedoTo returns the action, action data, and state at the given index, |
| 267 | // returning nil if already at end of saved records. |