/// Convert the given offset to a utf-16 line and character.
Convert the given offset to a utf-16 line and character.
Convert the given offset to a utf - 16 line and character .
pub fn position_to_unicode_line_char(&self, offset: usize) -> (usize, usize) {
        if offset == 0 {
            return (0, 0);
        }
        let line = match self.line_starts.binary_search(&offset) {
            Ok(exact) => exact,
            Err(0) => return (0, 0),
            Err(n) => n - 1,
        };
        let line_start = self.line_starts[line];
        let rest = &self.source[line_start..];
        let offset = offset - line_start;
        let mut line_count = 0;
        for (n, _) in rest.char_indices() {
            if n == offset {
                return (line, line_count);
            }
            if n > offset {
                break;
            }
            line_count += 1;
        }
        (line, line_count)
    }
pub fn position_to_unicode_line_char ( & self , offset : usize ) -> ( usize , usize ) { if offset == 0 { return ( 0 , 0 ) ; } let line = match self . line_starts . binary_search ( & offset ) { Ok ( exact ) => exact , Err ( 0 ) => return ( 0 , 0 ) , Err ( n ) => n - 1 , } ; let line_start = self . line_starts [ line ] ; let rest = & self . source [ line_start .. ] ; let offset = offset - line_start ; let mut line_count = 0 ; for ( n , _ ) in rest . char_indices ( ) { if n == offset { return ( line , line_count ) ; } if n > offset { break ; } line_count += 1 ; } ( line , line_count ) }
Convert the given offset to a utf-16 line and character.
Convert the given offset to a utf - 16 line and character .
&self
offset
usize