Byte offsets of each line start, for UTF-16 column conversion.
(src: &str)
| 80 | |
| 81 | /// Byte offsets of each line start, for UTF-16 column conversion. |
| 82 | pub 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. |
no outgoing calls