MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / byte_offset_to_utf16_col

Function byte_offset_to_utf16_col

src/util.rs:402–411  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

400/// Returns the total UTF-16 length of the line if `byte_offset` is past
401/// the end.
402pub(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.

Callers 1

detect_docblock_triggerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected