forge
Explore
Log in

Don't you dare go Hollow

Use toggle_full_width() for expand-column-to-available-width edge case

Browse files at this commit

652d2923bb963b16b481b91ce03b2fedd456dc17Ivan MolodetskikhParent: 85349ce
src/layout/scrolling.rsmodified+14 -4
@@ -2555,6 +2555,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
25552555 let mut width_taken = 0.;
25562556 let mut leftmost_col_x = None;
25572557 let mut active_col_x = None;
2558+ let mut counted_non_active_column = false;
25582559
25592560 let gap = self.options.gaps;
25602561 let col_xs = self.column_xs(self.data.iter().copied());
@@ -2574,6 +2575,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {
25742575
25752576 if idx == self.active_column_idx {
25762577 active_col_x = Some(col_x);
2578+ } else {
2579+ counted_non_active_column = true;
25772580 }
25782581
25792582 width_taken += width + gap;
@@ -2590,16 +2593,23 @@ impl<W: LayoutElement> ScrollingSpace<W> {
25902593 return;
25912594 }
25922595
2593- let active_width = self.data[self.active_column_idx].width;
2594-
25952596 let col = &mut self.columns[self.active_column_idx];
2597+ cancel_resize_for_column(&mut self.interactive_resize, col);
2598+
2599+ if !counted_non_active_column {
2600+ // Only the active column was fully on-screen (maybe it's the only column), so we're
2601+ // about to set its width to 100% of the working area. Let's do it via
2602+ // toggle_full_width() as it lets you back out of it more intuitively.
2603+ col.toggle_full_width();
2604+ return;
2605+ }
2606+
2607+ let active_width = self.data[self.active_column_idx].width;
25962608 col.width = ColumnWidth::Fixed(active_width + available_width);
25972609 col.preset_width_idx = None;
25982610 col.is_full_width = false;
25992611 col.update_tile_sizes(true);
26002612
2601- cancel_resize_for_column(&mut self.interactive_resize, col);
2602-
26032613 // Put the leftmost window into the view.
26042614 let new_view_x = leftmost_col_x.unwrap() - gap - working_x;
26052615 self.animate_view_offset(self.active_column_idx, new_view_x - active_col_x.unwrap());