Convert a byte offset within a single line to a UTF-16 column offset. This is the inverse of [`utf16_col_to_byte_offset`]. It counts UTF-16 code units for all characters before `byte_offset` and returns the result. Returns the total UTF-16 length of the line if `byte_offset` is past the end.
(line: &str, byte_offset: usize)
| 400 | /// Returns the total UTF-16 length of the line if `byte_offset` is past |
| 401 | /// the end. |
| 402 | pub(crate) fn byte_offset_to_utf16_col(line: &str, byte_offset: usize) -> u32 { |
| 403 | let mut col = 0u32; |
| 404 | for (i, ch) in line.char_indices() { |
| 405 | if i >= byte_offset { |
| 406 | return col; |
| 407 | } |
| 408 | col += ch.len_utf16() as u32; |
| 409 | } |
| 410 | col |
| 411 | } |
| 412 | |
| 413 | /// Extract the short (unqualified) class name from a potentially |
| 414 | /// fully-qualified name. |
no outgoing calls
no test coverage detected