From 8eea49a688e271625a1f3a6469a55dfadd0e6232 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 28 Oct 2022 00:30:26 +0200 Subject: [PATCH] grid flatten: fix corner case when chunk shrinks to zero area wrong integer cast caused endless iterator --- nested/src/grid/flatten.rs | 8 ++++---- nested/src/sequence/flatten.rs | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/nested/src/grid/flatten.rs b/nested/src/grid/flatten.rs index 3fffc18..8010cac 100644 --- a/nested/src/grid/flatten.rs +++ b/nested/src/grid/flatten.rs @@ -197,12 +197,12 @@ where let old_limit = self.limit; self.limit = Point2::new( - (0..=top_range.end().x as usize) - .map(|x| col_widths.get(x).unwrap_or(&0)) + (0..=top_range.end().x) + .map(|x| col_widths.get(x as usize).unwrap_or(&0)) .sum::() - 1, - (0..=top_range.end().y as usize) - .map(|y| row_heights.get(y).unwrap_or(&0)) + (0..=top_range.end().y) + .map(|y| row_heights.get(y as usize).unwrap_or(&0)) .sum::() - 1, ); diff --git a/nested/src/sequence/flatten.rs b/nested/src/sequence/flatten.rs index 8487563..f59aeb2 100644 --- a/nested/src/sequence/flatten.rs +++ b/nested/src/sequence/flatten.rs @@ -65,7 +65,6 @@ where } } -/* TODO: remove unused projection args (bot-views) if they get replaced by a new viewport */ impl Flatten where Item: 'static, @@ -163,11 +162,9 @@ where let old_length = self.length; self.length = cur_offset; -/* FIXXME: causes hangup - if self.length < old_length { - dirty_idx.extend(self.length..old_length); - } - */ + + dirty_idx.extend(self.length..old_length); + dirty_idx }