cleanForwardChanges method

void cleanForwardChanges()

Clean forward changes in the history.

This method removes any changes made after the current edit position in the history. It ensures that the state history and screenshots are consistent with the current position. This is useful when performing an undo operation, and new edits are made, effectively discarding the "redo" history.

Implementation

void cleanForwardChanges() {
  if (stateHistory.length > 1) {
    while (position < stateHistory.length - 1) {
      stateHistory.removeLast();
    }
    while (position < screenshots.length) {
      screenshots.removeLast();
    }
  }
  position = stateHistory.length - 1;
}