public static boolean isTextRangeFolded(@NotNull Editor editor, @NotNull TextRange range) {
    FoldRegion foldRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(range.getStartOffset());
    return foldRegion != null && range.getEndOffset() <= foldRegion.getEndOffset();
  }
public static boolean isTextRangeFolded(@NotNull Editor editor, @NotNull TextRange range)