gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 684HTML 640Markdown 12TOML 62286 Definitions

Fix: Calculate correct new grid size when expanding cell_occupancy_matrix in the negative direction (#843)

Signed-off-by: Nico Burns <nico@nicoburns.com>

5db1a9d99aeb127615eb3d3dae90d83e7d5eaace · by Nico Burns · (1 year ago) · parent f391b9f5c · browse the tree at this commit

Semantic delta · 1

src/compute/grid/types/cell_occupancy.rs

1 files · +2 −2

diff --git a/src/compute/grid/types/cell_occupancy.rs b/src/compute/grid/types/cell_occupancy.rs
index c0fb63b3e..d6c4017a2 100644
--- a/src/compute/grid/types/cell_occupancy.rs
+++ b/src/compute/grid/types/cell_occupancy.rs
@@ -90,9 +90,9 @@ impl CellOccupancyMatrix {
     /// Expands the grid (potentially in all 4 directions) in order to ensure that the specified range fits within the allocated space
     fn expand_to_fit_range(&mut self, row_range: Range<i16>, col_range: Range<i16>) {
         // Calculate number of rows and columns missing to accommodate ranges (if any)
-        let req_negative_rows = min(row_range.start, 0);
+        let req_negative_rows = -min(row_range.start, 0);
         let req_positive_rows = max(row_range.end - self.rows.len() as i16, 0);
-        let req_negative_cols = min(col_range.start, 0);
+        let req_negative_cols = -min(col_range.start, 0);
         let req_positive_cols = max(col_range.end - self.columns.len() as i16, 0);
 
         let old_row_count = self.rows.len();