private boolean drawWithClipping(int index, Graphics2D g, Font font, float x1, float x2, float baseline) {
    if (!SystemInfo.isMacOSCatalina || !myDynamicSearchMatchHighlighting) return false;
    ColoredFragment fragment = myFragments.get(index);
    if (!fragment.attributes.isSearchMatch()) return false;
    ColoredFragment prevFragment = index > 0 ? myFragments.get(index - 1) : null;
    ColoredFragment nextFragment = index < myFragments.size() - 1 ? myFragments.get(index + 1) : null;
    boolean okToMerge = prevFragment != null || nextFragment != null;
    if (okToMerge && prevFragment != null) {
      okToMerge = ((prevFragment.attributes.getStyle() | SimpleTextAttributes.STYLE_SEARCH_MATCH) == fragment.attributes.getStyle());
    }
    if (okToMerge && nextFragment != null) {
      okToMerge = ((nextFragment.attributes.getStyle() | SimpleTextAttributes.STYLE_SEARCH_MATCH) == fragment.attributes.getStyle());
    }
    if (okToMerge) {
      String mergedText = (prevFragment != null ? prevFragment.text : "")
                          + fragment.text
                          + (nextFragment != null ? nextFragment.text : "");
      Graphics2D clippedGraphics = (Graphics2D)g.create();
      try {
        clippedGraphics.clip(new Rectangle2D.Float(x1, 0, x2 - x1, getHeight()));

        if (prevFragment != null) x1 -= computeStringWidth(prevFragment, index - 1, font);
        clippedGraphics.drawString(mergedText, x1, baseline);
      }
      finally {
        clippedGraphics.dispose();
      }
      return true;
    }
    return false;
  }
private boolean drawWithClipping(int index, Graphics2D g, Font font, float x1, float x2, float baseline)