public int getSourceLineNumberForOffset ( final int offset ) { int lineNumber = - 1 ; lineNumber = 0 ; for ( ; lineNumber < this . lineStartOffsets . length - 1 ; lineNumber ++ ) { if ( this . lineStartOffsets [ lineNumber + 1 ] > offset ) { break ; } } if ( offset > lineStartOffsets [ lineStartOffsets . length - 1 ] ) { lineNumber = lineStartOffsets . length - 1 ; } // we now have line number, but it's 0-based. Need to convert to 1-based return lineNumber + 1 ; }
1st character of the line it was usually returning the following line