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

Function line_starts

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

80
81/// Byte offsets of each line start, for UTF-16 column conversion.
82pub fn line_starts(src: &str) -> Vec<usize> {
83 let mut out = vec![0usize];
84 for (i, b) in src.bytes().enumerate() {
85 if b == b'\n' {
86 out.push(i + 1);
87 }
88 }
89 out
90}
91
92/// UTF-16 code units in `s` — what web-tree-sitter (and JS string ops)
93/// 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

no outgoing calls

Tested by 1

utf16_colsFunction · 0.56