private static boolean isSelected(FoldRegion foldRegion) {
      int regionStart = foldRegion.getStartOffset();
      int regionEnd = foldRegion.getEndOffset();
      int[] selectionStarts = foldRegion.getEditor().getSelectionModel().getBlockSelectionStarts();
      int[] selectionEnds = foldRegion.getEditor().getSelectionModel().getBlockSelectionEnds();
      for (int i = 0; i < selectionStarts.length; i++) {
        int start = selectionStarts[i];
        int end = selectionEnds[i];
        if (regionStart >= start && regionEnd <= end) return true;
      }
      return false;
    }
private static boolean isSelected(FoldRegion foldRegion)