hasCachedLineSpan method

bool hasCachedLineSpan(
  1. int lineIndex,
  2. String lineText
)

Returns whether a highlighted span is already available without doing syntax parsing. Rendering must use this on a scroll frame: parsing a newly visible group of lines in paint blocks the UI isolate.

Implementation

bool hasCachedLineSpan(int lineIndex, String lineText) {
  final mergedCache = _mergedCache[lineIndex];
  if (mergedCache != null &&
      mergedCache.version == _version &&
      mergedCache.text == lineText) {
    return true;
  }

  final grammarCache = _grammarCache[lineIndex];
  final hasGrammar =
      grammarCache != null &&
      grammarCache.version == _version &&
      grammarCache.text == lineText;
  return hasGrammar;
}