TextRange (LineFragment o) { int start = o.getStartOffset2(); int end = o.getEndOffset2(); int prevLineStart = myContent.lastIndexOf('\n', start - 2) + 1; return new TextRange(prevLineStart, Math.max(start, end - 1)); }