int (@NotNull Document document) { if (line >= document.getLineCount()) return document.getTextLength(); return Math.min(document.getLineStartOffset(line) + column, document.getLineEndOffset(line)); }