public static int yToLogicalLineNoCustomRenderers(@NotNull Editor editor, int y) {
    return ReadAction.compute(() -> {
      int visualLine = editor.yToVisualLine(y);
      int visualLineStartY = editor.visualLineToY(visualLine);
      if (y < visualLineStartY || y >= visualLineStartY + editor.getLineHeight()) return -1;
      int line = editor.visualToLogicalPosition(new VisualPosition(visualLine, 0)).line;
      Document document = editor.getDocument();
      if (line < document.getLineCount()) {
        int lineStartOffset = document.getLineStartOffset(line);
        FoldRegion foldRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(lineStartOffset);
        if (foldRegion instanceof CustomFoldRegion) {
          return -1;
        }
      }
      return line;
    });
  }
public static int yToLogicalLineNoCustomRenderers(@NotNull Editor editor, int y)