SIGN IN SIGN UP

feat(viewer): number the lines inside the Existing Code block (#1172) (#1180)

The session page showed the line range as a single L120-L124 chip above the
comment text and printed the code block with no numbers, so mapping "the third
line of this snippet" back to the editor meant counting by hand.

Number each line of the Existing Code block in a non-selectable gutter. The
chip is redundant once the gutter carries the numbers, so it is hidden
visually, but it stays in the accessibility tree: the gutter itself is
aria-hidden so a screen reader does not read a number before every line, and
without the chip there would be no line location left to announce at all.

The numbers are only emitted when EndLine-StartLine+1 equals the number of
lines in ExistingCode. internal/diff/resolver.go drops blank lines on both
sides while matching, so the span can disagree with the snippet. When it does,
the block renders exactly as before rather than showing numbers that point at
the wrong code.

A zero EndLine is treated as a single-line finding. An inverted non-zero range
is left alone so the length check rejects it, matching the hasRegion test in
cmd/opencodereview/sarif.go.

Signed-off-by: ChethanUK <chethanuk@outlook.com>
C
chethanuk committed
7f8fa44f8f27b940187897c2ac2e5851b9d9322c
Parent: e967f3f
Committed by GitHub <noreply@github.com> on 9/6/2026, 3:18:34 PM