Skip to content

fix(confirm): clear screen on resize to prevent duplicated prompt text - #1091

Open
syf2211 wants to merge 1 commit into
charmbracelet:mainfrom
syf2211:fix/426-confirm-resize-clear
Open

fix(confirm): clear screen on resize to prevent duplicated prompt text#1091
syf2211 wants to merge 1 commit into
charmbracelet:mainfrom
syf2211:fix/426-confirm-resize-clear

Conversation

@syf2211

@syf2211 syf2211 commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Fixes a terminal resize artifact in gum confirm where the prompt (and sometimes buttons) appeared duplicated after shrinking and growing the viewport.

Motivation

Fixes #426. gum confirm renders inline (no alt screen). When the terminal width changes, lipgloss-wrapped prompt lines can leave stale content on screen because the new frame may be shorter than the previous one.

Changes

  • Store terminal width on tea.WindowSizeMsg
  • Return tea.ClearScreen on resize to remove stale wrapped lines before redraw
  • Apply MaxWidth to the prompt based on available content width (terminal width minus horizontal padding)
  • Add unit tests for resize handling and content width calculation

Tests

go test ./confirm/... -count=1 -v
go test ./... -count=1

Result: PASS

Notes

  • Reviewed with composer-2.5: APPROVE
  • Manual resize repro from the issue should be verified in a real terminal when possible

When gum confirm renders inline without the alt screen, shrinking or
growing the viewport leaves stale wrapped prompt/button lines visible.
Clear the screen on WindowSizeMsg and constrain prompt wrapping to the
available content width.

Fixes charmbracelet#426
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.

gum confirm question replicates when shrinking and growing the terminal viewport

2 participants