Repository navigation
Closed
Labels
bugSomething isn't working
Description
Summary
PromptZone in src/libvt/events.py and ImagePlacement in src/libvt/graphics.py (#2, #14) expose a signed row: int attribute that turns negative once the anchor scrolls into history. Passing zone.row or placement.row into Snapshot[row] triggers Python negative sequence indexing from the bottom of the active viewport instead of addressing scrollback, and any viewport row stored on a persistent event or placement record goes stale after the next scroll linefeed.
Reproduction
- Emit an
OSC 133;Aprompt marker, scroll it one row intohistory, and indexsnap[pz.row]:
uv run python -c 'from libvt import Terminal; vt = Terminal(rows=2, cols=10, scrollback=10); vt.feed(b"\x1b]133;A\x07cmd\r\nline1\r\nline2"); snap = vt.snapshot(); pz = snap.prompt_zones[0]; print("abs_row:", pz.abs_row, "row:", pz.row, "snap[pz.row]:", repr(snap[pz.row].text))'
Expected
PromptZoneandImagePlacementcarry only monotonicabs_row: int(andcol: int) without a signedrowfield that aliasesSnapshot[-1].Snapshot.at_abs(abs_row)returns theRowViewfromhistoryor the active viewport (or raisesIndexError/ returnsNoneviaSnapshot.viewport_row(abs_row) -> int | Nonewhen evicted or insidehistory), matching WezTerm (repo,wezterm-surfaceStableRowIndexatee6f3044d) stable row addressing.
Actual
abs_row: 0 row: -1 snap[pz.row]: 'line2' — snap[pz.row] reads the bottom viewport row 'line2' instead of scrollback row 'cmd'.
Environment
Versions
libvt:#2(0.1.0a0)- Python:
3.15.1 - OS: Linux
x86_64
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
PromptZoneandImagePlacementstoreabs_row: intand omit signedrow: int, closing theSnapshot[-1]negative-indexing footgun before0.1.0locks public fields.Snapshot.viewport_row(abs_row)returns0 <= r < rowswhen abs_row is visible in the snapshot's active viewport andNonewhen abs_row lies in scrollback or has been evicted.Snapshot.at_abs(abs_row)resolves any retained row across scrollback plus the primary viewport inO(1)time and raisesIndexErrorwhen abs_row was evicted or out of range.
Intent (non-binding)
- Record
scrolled_totalandevicted_totalonSnapshotsoat_abs(abs_row),viewport_row(abs_row), andImagePlacement.occupies_viewport_cell(row, col, scrolled_total=...)(orSnapshot-scoped helpers) need no mutable screen reference. - Include
abs_row(and computedviewport_row) inSnapshot.to_dict()placement records.
Not doing
- Storing a mutable or snapshot-relative
viewport_rowfield onPromptZoneorImagePlacementinstances emitted inPromptMarkevents.
References
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
terminal(feat[coords]): Resolve rows via at_abs (#19)
tony commentedon Nov 23, 2026
Resolved in #2 (
0c7ee41).