cancelPendingHistoryFlushes method

void cancelPendingHistoryFlushes()

Drop coalesced history wheel/pan/fling deltas. Call before absolute scroll (scrollbar, ScrollTo*) so a pending flush cannot override the target position on the next microtask/frame.

Pair with drainHistoryScroll before absolute engine scroll so an in-flight scrollPixels / scrollLines cannot race past cancel.

Implementation

void cancelPendingHistoryFlushes() {
  if (_pendingHistoryPx != 0 ||
      _pendingHistoryLines != 0 ||
      _historyScheduled) {
    TerminalScrollTrace.log(
      'controller',
      'cancelPendingHistoryFlushes px=$_pendingHistoryPx lines=$_pendingHistoryLines',
    );
  }
  _pendingHistoryPx = 0;
  _pendingHistoryLines = 0;
  _historyScheduled = false;
  _historyGeneration++;
  stopFling();
  _notifyHistoryIdle();
}