Skip to content

fix(vt): clamp scroll margins to screen bounds - #954

Open
trentkm wants to merge 1 commit into
charmbracelet:mainfrom
trentkm:fix-vt-scroll-margin-bounds
Open

fix(vt): clamp scroll margins to screen bounds#954
trentkm wants to merge 1 commit into
charmbracelet:mainfrom
trentkm:fix-vt-scroll-margin-bounds

Conversation

@trentkm

@trentkm trentkm commented Aug 20, 2026

Copy link
Copy Markdown

Out-of-range DECSTBM and DECSLRM trailing margins were stored beyond the render buffer. A later reverse-index (ESC M) passed that rectangle to ultraviolet and panicked while indexing the first cell outside the grid.

Clamp bottom and right margins to the current screen dimensions, while preserving the existing handling of one-cell regions at the lower/right edge. Reject leading margins that begin beyond the screen.

This was observed in a live terminal resize and reduces to:

term := vt.NewEmulator(30, 4)
term.Write([]byte("\x1b[?69h\x1b[1;31s\x1b[H\x1bM"))

Tests cover both DECSTBM and DECSLRM bounds.

Tested with go test ./... from vt/.

Downstream report: trentkm/stormlight#199

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant