public static Offset rangeToTextOffset(CharSequence charsSequence, Comment.Range range) {
int startOffset = 0;
int endOffset = 0;
try {
BufferedReader reader = new BufferedReader(new CharSequenceReader(charsSequence));
String line;
int textLineCount = 1;
while ((line = reader.readLine()) != null) {
if (textLineCount < range.startLine) {
startOffset += line.length();