int getFoldedLinesCountBefore(int offset) {
    if (!isFoldingEnabled()) return 0;
    CachedData cachedData = ensureAvailableData();
    int idx = getLastTopLevelIndexBefore(cachedData, offset);
    if (idx == -1) return 0;
    assert cachedData.topFoldedLines != null;
    return cachedData.topFoldedLines[idx];
  }
int getFoldedLinesCountBefore(int offset)