fix: shrinking terminal on new tab#1586
Open
ddidderr wants to merge 1 commit into
Open
Conversation
After a layout pass, a single-panel context's dimension stores the inner content area, not the window size. Opening a new tab copied that into the new ContextGrid, which subtracted margins again so each new tab lost columns/rows until a real resize. Use grid_dimension() unconditionally; it rebuilds from the grid's preserved window size. Refresh the Taffy root size on margin change so calculate_positions() stays in sync.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression where opening successive tabs could progressively shrink the terminal grid because a laid-out single-panel tab’s stored ContextDimension reflected the inner content area (already margin-adjusted), and that dimension was reused as if it were the window size.
Changes:
- Always derive the dimension for new tabs from
current_grid().grid_dimension()to preserve the grid’s window-sized dimensions. - Refresh the Taffy root size when the scaled margin changes by calling
try_update_sizefromupdate_scaled_margin. - Add a regression test to ensure new tabs remain window-sized after a layout pass and margin changes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| frontends/rioterm/src/layout/mod.rs | Updates margin handling to keep Taffy root sizing in sync when margins change. |
| frontends/rioterm/src/context/mod.rs | Uses grid_dimension() unconditionally when creating new contexts and adds a regression test for the tab-shrinking scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| pub fn update_scaled_margin(&mut self, scaled_margin: Margin) { | ||
| self.scaled_margin = scaled_margin; | ||
| let _ = self.try_update_size(self.width, self.height); |
Author
There was a problem hiding this comment.
The return value is ignored by another invocation of try_update_size in the same file so I guess authors are fine with this style.
Comment on lines
+1286
to
+1291
| assert!( | ||
| (initial_panel_height | ||
| - updated_panel_height | ||
| - (margin.top - initial_margin.top)) | ||
| .abs() | ||
| < f32::EPSILON |
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.
After a layout pass, a single-panel context's dimension stores the inner content area, not the window size. Opening a new tab copied that into the new ContextGrid, which subtracted margins again so each new tab lost columns/rows until a real resize.
Use grid_dimension() unconditionally; it rebuilds from the grid's preserved window size. Refresh the Taffy root size on margin change so calculate_positions() stays in sync.