int () { int endOffset = getEndOffset(); return switch (getTargetArea()) { case EXACT_RANGE -> endOffset; case LINES_IN_RANGE -> { Document document = myModel.getDocument(); int textLength = document.getTextLength(); if (endOffset >= textLength) yield endOffset; yield Math.min(textLength, document.getLineEndOffset(document.getLineNumber(endOffset)) + 1); } }; }