int (int caretOffset, List<? extends XLineBreakpointType.XLineBreakpointVariant> variants) { assert !variants.isEmpty(); TextRange bestRange = null; int bestIndex = -1; for (int i = 0; i < variants.size(); i++) { var variant = variants.get(i); TextRange range = variant.getHighlightRange(); if (range != null && range.contains(caretOffset)) { if (bestRange == null || bestRange.getLength() > range.getLength()) { bestRange = range; bestIndex = i; } } } // Use first variant if nothing interesting is found. return bestIndex == -1 ? 0 : bestIndex; }