Byte offsets of each line start, for UTF-16 column conversion.
(src: &str)
| 132 | |
| 133 | /// Byte offsets of each line start, for UTF-16 column conversion. |
| 134 | pub 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. |