1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Helpers for iterating line-oriented views over raw file bytes.
/// Visit each logical line in `content`.
///
/// Lines are split on `\n`. A preceding `\r` is trimmed so that `\r\n`
/// behaves like a single line ending. The callback receives:
/// - 1-based line number
/// - byte offset of the line start in the original content
/// - line bytes without trailing newline
///
/// # Mixed line endings (`\r\n` and `\n` in the same file)
///
/// Each line is handled independently: if a `\n` is preceded by `\r`, the
/// `\r` is excluded from the line slice but `line_start` always advances to
/// the byte after the `\n`. This means byte offsets are correct regardless
/// of whether any given line uses `\r\n` or bare `\n`. No per-line offset
/// drift occurs.
///
/// # Classic Mac `\r`-only files
///
/// Files using `\r` as the sole line separator (no `\n`) are treated as a
/// single line. This matches ripgrep behaviour, maintaining SC-004 correctness
/// parity. Matches in such files report `line_number: 1`.
pub