mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Save last layout width in List
to avoid unnecessary re-renders
This commit is contained in:
parent
477740360d
commit
0a22dee764
1 changed files with 13 additions and 2 deletions
|
@ -17,7 +17,7 @@ pub struct List {
|
|||
#[derive(Clone)]
|
||||
pub struct ListState(Rc<RefCell<StateInner>>);
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum Orientation {
|
||||
Top,
|
||||
Bottom,
|
||||
|
@ -47,6 +47,16 @@ enum ListItem {
|
|||
Removed(f32),
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for ListItem {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Unrendered => write!(f, "Unrendered"),
|
||||
Self::Rendered(_) => f.debug_tuple("Rendered").finish(),
|
||||
Self::Removed(height) => f.debug_tuple("Removed").field(height).finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
struct ListItemSummary {
|
||||
count: usize,
|
||||
|
@ -228,7 +238,8 @@ impl Element for List {
|
|||
drop(cursor);
|
||||
state.items = new_items;
|
||||
state.rendered_range = new_rendered_range_start..new_rendered_range_end;
|
||||
(constraint.max, scroll_top)
|
||||
state.last_layout_width = Some(size.x());
|
||||
(size, scroll_top)
|
||||
}
|
||||
|
||||
fn paint(&mut self, bounds: RectF, scroll_top: &mut ScrollTop, cx: &mut PaintContext) {
|
||||
|
|
Loading…
Reference in a new issue