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

Function col16

codegraph-kernel/src/textutil.rs:151–157  ·  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

149
150/// Column (UTF-16 units) of `byte_pos` on line `row`, given `line_starts`.
151pub fn col16(src: &str, starts: &[usize], row: usize, byte_pos: usize) -> u32 {
152 let ls = starts.get(row).copied().unwrap_or(0);
153 if byte_pos <= ls {
154 return 0;
155 }
156 utf16_len(&src[ls..byte_pos]) as u32
157}
158
159/// JS `String.prototype.slice(0, n)` in UTF-16 units, without splitting a
160/// 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