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> {
2555 let mut width_taken = 0.;2555 let mut width_taken = 0.;
2556 let mut leftmost_col_x = None;2556 let mut leftmost_col_x = None;
2557 let mut active_col_x = None;2557 let mut active_col_x = None;
2558+ let mut counted_non_active_column = false;
2558 2559
2559 let gap = self.options.gaps;2560 let gap = self.options.gaps;
2560 let col_xs = self.column_xs(self.data.iter().copied());2561 let col_xs = self.column_xs(self.data.iter().copied());
@@ -2574,6 +2575,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2574 2575
2575 if idx == self.active_column_idx {2576 if idx == self.active_column_idx {
2576 active_col_x = Some(col_x);2577 active_col_x = Some(col_x);
2578+ } else {
2579+ counted_non_active_column = true;
2577 }2580 }
2578 2581
2579 width_taken += width + gap;2582 width_taken += width + gap;
@@ -2590,16 +2593,23 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2590 return;2593 return;
2591 }2594 }
2592 2595
2593- let active_width = self.data[self.active_column_idx].width;
2594-
2595 let col = &mut self.columns[self.active_column_idx];2596 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;
2596 col.width = ColumnWidth::Fixed(active_width + available_width);2608 col.width = ColumnWidth::Fixed(active_width + available_width);
2597 col.preset_width_idx = None;2609 col.preset_width_idx = None;
2598 col.is_full_width = false;2610 col.is_full_width = false;
2599 col.update_tile_sizes(true);2611 col.update_tile_sizes(true);
2600 2612
2601- cancel_resize_for_column(&mut self.interactive_resize, col);
2602-
2603 // Put the leftmost window into the view.2613 // Put the leftmost window into the view.
2604 let new_view_x = leftmost_col_x.unwrap() - gap - working_x;2614 let new_view_x = leftmost_col_x.unwrap() - gap - working_x;
2605 self.animate_view_offset(self.active_column_idx, new_view_x - active_col_x.unwrap());2615 self.animate_view_offset(self.active_column_idx, new_view_x - active_col_x.unwrap());