fix(display): don't emit stray newline on repaint of empty buffer - #123
Merged
maxlandon merged 2 commits intoSep 30, 2026
Merged
Conversation
The wrap heuristic used len(line), but line is the rendered string and always contains ANSI escape codes, so it was non-empty even when the input buffer was empty. With a zero-width primary prompt this caused a spurious newline on every repaint (startup, backspace on an empty line). Use the actual buffer length instead.
Member
|
Thanks for the fix ! |
maxlandon
enabled auto-merge
September 30, 2026 12:29
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #123 +/- ##
=======================================
Coverage 39.82% 39.82%
=======================================
Files 60 60
Lines 9594 9594
=======================================
Hits 3821 3821
Misses 5679 5679
Partials 94 94 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Repainting an empty input line with a zero-width primary prompt emitted a spurious newline — one blank line at startup and one more per repaint of an empty buffer (e.g. backspace on an empty line), causing the display to scroll and drift.
Root cause
In
internal/display/refresh.go,displayLine()computed:lineis the rendered string and always contains ANSI escape codes (selection/background resets, autosuggest styling) even when the input buffer is empty, solen(line) > 0is always true. When the primary prompt is zero-width,e.lineCol == 0too, so the forced-wrap newline fired on every repaint of an empty buffer.Fix
Test the actual buffer length instead of the rendered string's:
Testing
go build ./...passesgo test ./internal/display/passesrl.Prompt.Primary(func() string { return "" }), no newline is emitted at startup or on backspace of an empty line; wrapped long lines still print correctlyVerified via a pty harness while integrating v1.3.0.