grid flatten: fix corner case when chunk shrinks to zero area

wrong integer cast caused endless iterator
This commit is contained in:
Michael Sippel 2022-10-28 00:30:26 +02:00
parent 273f20d3db
commit 8eea49a688
2 changed files with 7 additions and 10 deletions

View file

@ -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::<i16>()
- 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::<i16>()
- 1,
);

View file

@ -65,7 +65,6 @@ where
}
}
/* TODO: remove unused projection args (bot-views) if they get replaced by a new viewport */
impl<Item> Flatten<Item>
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
}