TextRange (@NotNull StringBuilder sb, @NotNull String line) { int startOffset = sb.length(); sb.append(line); if (!line.endsWith("\n")) { sb.append("\n"); } int endOffset = sb.length(); return TextRange.create(startOffset, endOffset); }