Repository navigation
fix: preserve exact-width lines printed above the view - #1888
Merged
andrinoff merged 2 commits intoNov 12, 2026
Merged
Conversation
andrinoff
approved these changes
Nov 12, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1888 +/- ##
==========================================
+ Coverage 64.05% 64.33% +0.27%
==========================================
Files 26 26
Lines 1430 1430
==========================================
+ Hits 916 920 +4
+ Misses 416 414 -2
+ Partials 98 96 -2 ☔ 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.
Fixes #1885.
tea.Printlnreserves an extra row when an inserted line fills exactly two or more terminal rows. It also clears to the right after writing the line, which can erase its last character while the terminal has a wrap pending.Count the additional rows with
(lineWidth - 1) / width, and clear the row before writing its text. This avoids erasing the final cell without keeping a separate array of measured widths. The existing width-measurement method is unchanged, so this can be combined with #1803 or #1861.The regression covers short lines, exact widths, one cell over, multiple rows, ANSI styling, wide characters, and multiple lines. Six cases fail on main and pass with the fix; the two non-boundary controls pass on both. The terminal reproduction is based on @n-eriksson's example in the issue.
Validation on macOS arm64:
go test ./...go test -race -count 4 -cpu 1,4 ./...go build ./...andgo vet ./...golangci-lint runwith v2.9.0go build ./...andgo test ./...inexamplesgo mod tidyin both modules leaves their module files unchangedThe issue's program in a 40-column PTY, with lines of 39, 40, 41, 80, and 120 cells, replayed through Charm's
x/vtemulator (v0.1.0) and xterm.js. The exact-multiple cases keep the full inserted line and redraw the inline view in place.x/vtreproduces both defects before the fix; xterm.js reproduces the broken view redraw.I have read
CONTRIBUTING.md.I have created a discussion that was approved by a maintainer (for new features). Not applicable: this fixes an existing bug.