Skip to content

rioterm: guard scrolling against a zero sized window - #1975

Open
theluckystrike wants to merge 1 commit into
raphamorim:mainfrom
theluckystrike:fix/890-zero-size-scroll
Open

theluckystrike wants to merge 1 commit into
raphamorim:mainfrom
theluckystrike:fix/890-zero-size-scroll

Conversation

@theluckystrike

@theluckystrike theluckystrike commented Oct 11, 2026 •

Copy link
Copy Markdown

Refs #890

Your #1747 already covers the working-dir half of #890, so this PR only fixes the scroll half.

The report's panic was an integer remainder by zero in screen/mod.rs. That code is floating point on main now, so a zero sized window doesn't panic anymore, but scroll() still divides by the cell height and width, and dividing by zero gives infinity. Cast to usize, that's the largest possible loop count, and the remainder at the end leaves the accumulator NaN for good.

Now a zero or negative dimension means no movement, and the accumulator keeps its value. Two small helpers carry the guard, each with a unit test. cargo test -p rioterm passes (223 tests), cargo fmt --check is clean, and clippy shows only the warning main already has in rio-vt.

Michael

Screen::scroll divided the accumulated scroll by the cell width and
height, so a zero sized window turned the scroll into an endless loop
(inf as usize) and left the accumulator NaN. Treat a zero or negative
dimension as no movement.

Refs raphamorim#890
@theluckystrike
theluckystrike force-pushed the fix/890-zero-size-scroll branch from 40a3c3d to 619ffc4 Compare October 11, 2026 05:38
@theluckystrike theluckystrike changed the title rioterm: validate the config working-dir and guard scrolling at zero size rioterm: guard scrolling against a zero sized window Oct 11, 2026

This branch has not been deployed

No deployments
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