Skip to content

fix: shrinking terminal on new tab#1586

Open
ddidderr wants to merge 1 commit into
raphamorim:mainfrom
ddidderr:fix_bug_termsize_newtab
Open

fix: shrinking terminal on new tab#1586
ddidderr wants to merge 1 commit into
raphamorim:mainfrom
ddidderr:fix_bug_termsize_newtab

Conversation

@ddidderr
Copy link
Copy Markdown

@ddidderr ddidderr commented May 4, 2026

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.

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.
Copilot AI review requested due to automatic review settings May 4, 2026 11:54
@ddidderr ddidderr changed the title fix shrinking terminal on new tab fix: shrinking terminal on new tab May 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_size from update_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);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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.

2 participants