szn

Bug 281 — searchBackward cyclic wrap (pass 2) skips the head of a wrapped logical line

281. searchBackward cyclic wrap (pass 2) skips the head of a wrapped logical line

File: src/mode_copy.zig:492–513 Severity: HIGH Status: ✅ FIXED — searchBackward now writes a WHOLE_LINE sentinel at the logical-line start (mirroring searchForward) and seeds start_col from the search origin’s column, so the back-search examines the whole wrapped logical line instead of only the tail physical line. Regression tests: searchBackward finds a foobar wrapped across lines 1-2 at the bottom with the cursor at the top (mode_copy.zig), and finds a match that crosses into the cursor’s own line only after the wrap.

Pass 2 of searchBackward starts at li = total -| 1 — the tail of the bottom logical line — and calls searchLogicalLineBackward there. lineBytes(li) reconstructs only from li forward, so a logical line that wraps across two physical lines (e.g. "foo"@line1 wrapped + "bar"@line2) is searched starting from "bar". The skip block then walks back to the line head and jumps past the whole logical line — the head "foo" is never searched.

Reproduced: grid [aaa] [foo→wrapped] [bar], cursor at line 0, searchBackward("foobar") returns false.

searchForward and searchBackward pass 1 both walk to the logical-line head first (bug #276); pass 2 of the backward search is the only path that searches from the tail. A match at the head of any wrapped line at the bottom of the scrollback is silently missed.