/// 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_utf16cu_line_char(&self, offset: usize) -> Option<(usize, usize)> {
        if offset == 0 {
            return Some((0, 0));
        }
        let line = match self.line_starts.binary_search(&offset) {
            Ok(exact) => exact,
            Err(0) => return None,
            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, c) in rest.char_indices() {
            if n == offset {
                return Some((line, line_count));
            }
            if n > offset {
                break;
            }
            line_count += c.encode_utf16(&mut [0u16; 2]).len();
        }
        Some((line, line_count))
    }
pub fn position_to_utf16cu_line_char ( & self , offset : usize ) -> Option < ( usize , usize ) > { if offset == 0 { return Some ( ( 0 , 0 ) ) ; } let line = match self . line_starts . binary_search ( & offset ) { Ok ( exact ) => exact , Err ( 0 ) => return None , 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 , c ) in rest . char_indices ( ) { if n == offset { return Some ( ( line , line_count ) ) ; } if n > offset { break ; } line_count += c . encode_utf16 ( & mut [ 0u16 ; 2 ] ) . len ( ) ; } Some ( ( 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