int (int logicalLine) { return logicalLine < myDocument.getLineCount() ? offsetToVisualLine(myDocument.getLineStartOffset(logicalLine)) : logicalToVisualPosition(new LogicalPosition(logicalLine, 0)).line; }