Skip to content

Commit 7bda168

Browse files
committed
fix: keep tab-bar margin transitions in sync with hide-if-single
resize_top_or_bottom_line compared the new padding against dimension.margin, but apply_taffy_layout zeroes dimension.margin on every run. Once that has happened the "previous" margin reads as zero; when num_tabs drops to 1 and hide_if_single makes padding_y_top zero too, the comparison short-circuits and update_scaled_margin is never called. Compare against the grid's scaled_margin (divided by scale) instead, since that holds the authoritative current margin. Without this, closing the second tab with hide-if-single enabled left the tab-bar strip reserved at the top and terminal content drew below it instead of filling the freed area.
1 parent 9387f24 commit 7bda168

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

  • frontends/rioterm/src/screen

frontends/rioterm/src/screen/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,8 +1580,6 @@ impl Screen<'_> {
15801580
}
15811581

15821582
pub fn resize_top_or_bottom_line(&mut self, num_tabs: usize) {
1583-
let layout = self.context_manager.current().dimension;
1584-
let previous_margin = layout.margin;
15851583
let padding_y_top = padding_top_from_config(
15861584
&self.renderer.navigation,
15871585
self.renderer.margin.top,
@@ -1590,8 +1588,16 @@ impl Screen<'_> {
15901588
);
15911589
let padding_y_bottom = self.renderer.margin.bottom;
15921590

1593-
if previous_margin.top != padding_y_top
1594-
|| previous_margin.bottom != padding_y_bottom
1591+
// Compare against the grid's scaled_margin (the actual current margin)
1592+
// rather than dimension.margin, which apply_taffy_layout zeroes out and
1593+
// therefore cannot tell us whether the top-bar margin changed.
1594+
let scale = self.sugarloaf.scale_factor();
1595+
let current_scaled_margin = self.context_manager.current_grid().scaled_margin;
1596+
let previous_margin_top = current_scaled_margin.top / scale;
1597+
let previous_margin_bottom = current_scaled_margin.bottom / scale;
1598+
1599+
if previous_margin_top != padding_y_top
1600+
|| previous_margin_bottom != padding_y_bottom
15951601
{
15961602
if let Some(layout) = self
15971603
.sugarloaf
@@ -1601,7 +1607,6 @@ impl Screen<'_> {
16011607
s.font_size = layout.font_size;
16021608
s.line_height = layout.line_height;
16031609

1604-
let scale = self.sugarloaf.scale_factor();
16051610
let d = self.context_manager.current_grid_mut();
16061611
d.update_scaled_margin(Margin::new(
16071612
padding_y_top * scale,

0 commit comments

Comments
 (0)