szn

Bug 409 — Keystrokes dropped

409. Keystrokes dropped: search-mode/n-repeat break out of processInput’s byte loop; client sd_buf smaller than worst-case forward makes serialize silently send nothing (#299 follow-up)

Severity: MEDIUM Status: ✅ RESOLVED

(a) Server side. Entering search mode on ?// and the n/N repeat handler end with break; inside the while (i < buf.len) byte loop (:1685, :1692). A pasted ?foo<CR> packet arrives in one read: ? opens search and every remaining byte (foo<CR>) is discarded — the search is never executed. The same drop-the-tail shape exists at :1734/:1767/:1881 (orelse return).

(b) Client side. fwd_scratch is [4096 + 64] (the #299 fix, correctly holding a 32-byte reply remainder + a full 4096-byte read), but the resulting forward is then serialized into var sd_buf: [4096 + 5] (main.zig:846). For forward.len in 4091..4128, Packet.serialize fails the size check and returns an empty slice (protocol.zig:77) → writeServer transmits nothing and the keystroke burst vanishes silently.

Fix: (a) stash the unprocessed remainder (or re-enter the loop) when switching modes; (b) size sd_buf to 4096 + 64 + 5 / serialize from a scratch that matches the worst case.