id: 3aeb0d21-a690-4369-82a2-cd7e75037ec7 title: 'diff: added lines starting +++/--- are misclassified as file headers' state: closed labels:
- ui assignees: [] milestone: null created: 2026-10-27T17:24:52.458393633Z updated: 2026-10-27T17:45:41.728512111Z
What
Diff lines are classified purely by prefix:
- added line whose content starts with
+++→ rendered++++ …and treated as a file header - added line whose content starts with
---→+--- …(this one is counted, but a removed line---- …is misclassified)
src/layout.rs:109-127: line.starts_with("+++") / starts_with("---") before the add/remove branches.
Reproduced
Append four lines to a tracked file: +++ not a header, --- not a header, @@ not a hunk, prefix+++line. The commit page reports +3 (4 actual added) and the ++++ not a header row is styled as a file header; subsequent new-side line numbers are off by one.
Impact
Wrong diffstat and line numbers; a reviewer can be misled about what changed (content can hide from the count).
Fix
Use diff position: +++/--- are headers only before the first @@ hunk (and +++ after ---); otherwise classify by the leading marker. Or require the a//b/ prefix for headers. Add a fixture test for content that starts with +++/---/@@.