cursorOnlyUpdate method

void cursorOnlyUpdate()

Notifies listeners for a cursor/selection-only change that does NOT mutate the document structure or text. Crucially it does NOT invalidate the content-derived caches (node index, caret-stop rail), so repeated arrow navigation reuses them instead of rebuilding O(n) on every press.

Listeners that are expensive on cursor-only changes can read cursorOnlyChange (true for the duration of this synchronous call) and skip unnecessary work.

Implementation

void cursorOnlyUpdate() {
  _cursorOnlyChange = true;

  _cachedCursorContainerId = cursor.focusId.isNotEmpty
      ? findLogicalContainerId(cursor.focusId)
      : null;
  cachedSelectionKey = null;
  cachedSelection = null;

  cursor.notifyListeners();
  notifyListeners();
  _cursorOnlyChange = false;
}