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

Function line_starts

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

Byte offsets of each line start, for UTF-16 column conversion.

(src: &str)

Source from the content-addressed store, hash-verified

132
133/// Byte offsets of each line start, for UTF-16 column conversion.
134pub fn line_starts(src: &str) -> Vec<usize> {
135 let mut out = vec![0usize];
136 for (i, b) in src.bytes().enumerate() {
137 if b == b'\n' {
138 out.push(i + 1);
139 }
140 }
141 out
142}
143
144/// UTF-16 code units in `s` — what web-tree-sitter (and JS string ops)
145/// count, so kernel-emitted columns are byte-identical to the wasm path's.

Callers 15

extractFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70
utf16_colsFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70
extractFunction · 0.70

Calls 2

bytesMethod · 0.80
pushMethod · 0.80

Tested by 1

utf16_colsFunction · 0.56