MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / col16

Function col16

codegraph-kernel/src/textutil.rs:99–105  ·  view source on GitHub ↗

Column (UTF-16 units) of `byte_pos` on line `row`, given `line_starts`.

(src: &str, starts: &[usize], row: usize, byte_pos: usize)

Source from the content-addressed store, hash-verified

97
98/// Column (UTF-16 units) of `byte_pos` on line `row`, given `line_starts`.
99pub fn col16(src: &str, starts: &[usize], row: usize, byte_pos: usize) -> u32 {
100 let ls = starts.get(row).copied().unwrap_or(0);
101 if byte_pos <= ls {
102 return 0;
103 }
104 utf16_len(&src[ls..byte_pos]) as u32
105}
106
107/// JS `String.prototype.slice(0, n)` in UTF-16 units, without splitting a
108/// surrogate pair (when the cut would split one, we stop one code unit short —

Callers 15

col_ofMethod · 0.85
end_col_ofMethod · 0.85
col_ofMethod · 0.85
end_col_ofMethod · 0.85
col_ofMethod · 0.85
end_col_ofMethod · 0.85
col_ofMethod · 0.85
end_col_ofMethod · 0.85

Calls 2

utf16_lenFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected