Fix terminal content hidden under the scroller after a font change#577
Fix terminal content hidden under the scroller after a font change#577bones7456 wants to merge 1 commit into
Conversation
bcdb82f to
5f80ac1
Compare
|
Friendly ping on this one 🙂 Now rebased on latest |
|
The CI failure is the pre-existing flaky The exact same failure shows up on |
|
Update on the CI failure: it's not flaky — Opened a separate test-only fix in #581 to keep it isolated from this font/scroller change. Once that merges, this PR's CI should go green on rebase. |
resetFont() recomputed the column count from the raw frame width, while the live window-resize path (processSizeChange) uses getEffectiveWidth(), which subtracts the reserved scroller width. After zooming the font the terminal therefore claimed more columns than fit the visible area, so the right-most columns were drawn underneath the scroller and that content was hidden. Zooming in and back out also drifted the reported column count by the scroller width. Compute the columns from getEffectiveWidth() in resetFont() as well, so the font-change and live-resize paths agree and content always stays clear of the scroller. Add macOS regression tests asserting the content stays within the usable (non-scroller) width and that both code paths report the same column count.
5f80ac1 to
64b5ef4
Compare
|
Rebased onto latest |
…hange; bump to 1.3.4 Pin the SwiftTerm dependency to the fork commit bones7456/SwiftTerm@64b5ef4 (PR migueldeicaza/SwiftTerm#577) which fixes the scroller/column-drift issue after changing font size. Revert to an upstream version tag once #577 is merged and a new SwiftTerm release ships.
|
Apologies, let me review now |
Problem
After changing the font size (zoom in/out), the right-most columns of the
terminal are drawn underneath the scroller and become hidden. Zooming
the font in and back out also leaves the reported column count off by a
couple of columns from what a window resize produces.
Root cause
The column/row count is computed in two places, and they disagree about
the scroller:
The live window-resize path,
processSizeChange(newSize:), usesgetEffectiveWidth(size:), which subtracts the reserved scroller width.resetFont()(invoked when the font changes) computed the columns fromthe raw
frame.width:So after a font change the terminal claims more columns than actually fit
in the visible (non-scroller) area, and the overflowing right-most columns
are rendered beneath the scroller.
Fix
Compute the columns from
getEffectiveWidth(size:)inresetFont()too,matching
processSizeChange. The function already exists and is used onboth macOS and iOS, so this keeps the two paths consistent and guarantees
content stays clear of the scroller.
Tests
Added
FontResizeColumnsTests(macOS) which:cols * cellDimension.width) stays withingetEffectiveWidth(size:)after a font change — i.e. content is notcovered by the scroller;
column count for the same frame.
Both tests fail on
main(e.g.renderedWidth 397.5 > usableWidth 383.0,and
53 != 51columns) and pass with this change. The rest of the suiteis unaffected (the single pre-existing
testSynchronizedOutputBlocksDisplayUntilResetfailure also reproduces on a clean
mainand is unrelated).