Skip to content

fix(term): clamp menu scroll on render to survive terminal resize#15678

Closed
lmarkmann wants to merge 1 commit intohelix-editor:masterfrom
lmarkmann:fix-menu-resize-panic
Closed

fix(term): clamp menu scroll on render to survive terminal resize#15678
lmarkmann wants to merge 1 commit intohelix-editor:masterfrom
lmarkmann:fix-menu-resize-panic

Conversation

@lmarkmann
Copy link
Copy Markdown

Closes #6382.

On a terminal resize, 'render' can run with 'area.height' smaller than
what 'adjust_scroll' last clamped against, so 'cursor - scroll'
underflows usize and 'surface[(.., area.y + offset_from_top)]' panics.
Re-clamping at the top of render closes the race regardless of which
of 'render' or 'recalculate_size' fires first. Same approach
pascalkuthe suggested in
#7089 (comment).

Repro on master: open completion in a tall terminal, scroll past the
new height, shrink the window. Crashes. With this patch the menu
redraws clamped and the cursor stays visible.

On a terminal resize, 'render' can run with 'area.height' smaller than
what 'adjust_scroll' last clamped against, so 'cursor - scroll'
underflows usize and the surface index panics. Re-clamp scroll at the
top of render against the area we're about to draw into, as
pascalkuthe suggested in #7089.

Closes #6382
@lmarkmann lmarkmann closed this by deleting the head repository May 2, 2026
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.

Panic when moving between monitors

1 participant