Skip to content

Commit

Permalink
Use toggle_full_width() for expand-column-to-available-width edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Feb 17, 2025
1 parent 85349ce commit 652d292
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/layout/scrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
let mut width_taken = 0.;
let mut leftmost_col_x = None;
let mut active_col_x = None;
let mut counted_non_active_column = false;

let gap = self.options.gaps;
let col_xs = self.column_xs(self.data.iter().copied());
Expand All @@ -2574,6 +2575,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {

if idx == self.active_column_idx {
active_col_x = Some(col_x);
} else {
counted_non_active_column = true;
}

width_taken += width + gap;
Expand All @@ -2590,16 +2593,23 @@ impl<W: LayoutElement> ScrollingSpace<W> {
return;
}

let active_width = self.data[self.active_column_idx].width;

let col = &mut self.columns[self.active_column_idx];
cancel_resize_for_column(&mut self.interactive_resize, col);

if !counted_non_active_column {
// Only the active column was fully on-screen (maybe it's the only column), so we're
// about to set its width to 100% of the working area. Let's do it via
// toggle_full_width() as it lets you back out of it more intuitively.
col.toggle_full_width();
return;
}

let active_width = self.data[self.active_column_idx].width;
col.width = ColumnWidth::Fixed(active_width + available_width);
col.preset_width_idx = None;
col.is_full_width = false;
col.update_tile_sizes(true);

cancel_resize_for_column(&mut self.interactive_resize, col);

// Put the leftmost window into the view.
let new_view_x = leftmost_col_x.unwrap() - gap - working_x;
self.animate_view_offset(self.active_column_idx, new_view_x - active_col_x.unwrap());
Expand Down

0 comments on commit 652d292

Please # to comment.