Visual Studio Code, rebuilt in Rust
Rust
fix(gpui): advance list rows by their rounded heights on request
rokarturdfbfefb60890
diff --git a/native/crates/app/src/workbench/settings_editor_view.rs b/native/crates/app/src/workbench/settings_editor_view.rsindex 0822268ca51..d37168e989c 100644--- a/native/crates/app/src/workbench/settings_editor_view.rs+++ b/native/crates/app/src/workbench/settings_editor_view.rs@@ -149,9 +149,7 @@ impl SettingsEditor {toc_focus: cx.focus_handle(),modal_focus: cx.focus_handle(),// settingsTree.ts rows have dynamic heights: listView.ts `probeDynamicHeight` reads their `offsetHeight`.- // shortcut: gpui-fast has no `with_whole_pixel_item_heights` (our Wu patch 40f47558cba), so rows advance by- // fractional heights; port the patch to round them again.- tree: ListState::new(0, ListAlignment::Top, px(400.)),+ tree: ListState::new(0, ListAlignment::Top, px(400.)).with_whole_pixel_item_heights(),toc_list: ListState::new(0, ListAlignment::Top, px(200.)),split: None,sash_hovered: false,diff --git a/native/vendor/gpui-fast/crates/gpui/src/elements/list.rs b/native/vendor/gpui-fast/crates/gpui/src/elements/list.rsindex 31d88aec779..51e9082f200 100644--- a/native/vendor/gpui-fast/crates/gpui/src/elements/list.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/elements/list.rs@@ -75,6 +75,7 @@ pub(crate) struct StateInner {pub(crate) follow_state: FollowState,pub(crate) version: crate::fast::dependencies::StateVersion,pub(crate) fast_measure: crate::fast::list_measure::DeferredMeasure,+ pub(crate) whole_pixel_item_heights: bool,}#[derive(Clone, Copy)]@@ -329,6 +330,7 @@ impl ListState {follow_state: FollowState::default(),version: crate::fast::dependencies::StateVersion::default(),fast_measure: crate::fast::list_measure::DeferredMeasure::default(),+ whole_pixel_item_heights: false,})));state.splice(0..0, item_count);state@@ -342,6 +344,12 @@ impl ListState {self}+ /// Rounds each measured item height to a whole pixel, as a DOM list that measures its rows with `offsetHeight`.+ pub fn with_whole_pixel_item_heights(self) -> Self {+ self.0.borrow_mut().whole_pixel_item_heights = true;+ self+ }+/// Pre-populate every unmeasured item with a uniform height hint so the scrollbar thumb/// is correctly sized from the first frame, without measuring all items up front.///@@ -1055,6 +1063,7 @@ impl StateInner {&mut element,ix,available_item_space,+ self.whole_pixel_item_heights,window,cx,)@@ -1136,6 +1145,7 @@ impl StateInner {&mut element,item_index,available_item_space,+ self.whole_pixel_item_heights,window,cx,);@@ -1192,6 +1202,7 @@ impl StateInner {&mut element,item_index,available_item_space,+ self.whole_pixel_item_heights,window,cx,);@@ -1259,6 +1270,7 @@ impl StateInner {&mut element,cursor.start().0,available_item_space,+ self.whole_pixel_item_heights,window,cx,)@@ -1312,6 +1324,7 @@ impl StateInner {&mut element,item_index,available_item_space,+ self.whole_pixel_item_heights,window,cx,);@@ -1411,6 +1424,7 @@ impl StateInner {&mut element,cursor.start().0,item_available_size,+ self.whole_pixel_item_heights,window,cx,)@@ -1445,6 +1459,7 @@ impl StateInner {&mut item,cursor.start().0,item_available_size,+ self.whole_pixel_item_heights,window,cx,)diff --git a/native/vendor/gpui-fast/crates/gpui/src/elements/uniform_list.rs b/native/vendor/gpui-fast/crates/gpui/src/elements/uniform_list.rsindex 202e8a02fcb..568e15d39b5 100644--- a/native/vendor/gpui-fast/crates/gpui/src/elements/uniform_list.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/elements/uniform_list.rs@@ -539,6 +539,7 @@ impl Element for UniformList {&mut item,ix,available_space,+ false,window,cx,);diff --git a/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rs b/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rsindex 808f1cf8589..ad539f0a2ee 100644--- a/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rs@@ -2162,8 +2162,14 @@ pub(crate) fn end_list(return height;}let mut element = render_item(row, window, cx);- let size =- crate::fast::layout_key::layout_as_list_item(&mut element, row, available, window, cx);+ let size = crate::fast::layout_key::layout_as_list_item(+ &mut element,+ row,+ available,+ state.whole_pixel_item_heights,+ window,+ cx,+ );rendered.insert(row, element);size.height};@@ -2347,6 +2353,7 @@ pub(crate) fn end_list(&mut element,row,available,+ state.whole_pixel_item_heights,window,cx,);diff --git a/native/vendor/gpui-fast/crates/gpui/src/fast/layout_key.rs b/native/vendor/gpui-fast/crates/gpui/src/fast/layout_key.rsindex 7e1ebf91cb3..87e15e9a4c0 100644--- a/native/vendor/gpui-fast/crates/gpui/src/fast/layout_key.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/fast/layout_key.rs@@ -274,17 +274,19 @@ pub(crate) fn pop_layout_key(window: &mut Window) {/// layout is keyed: element state, which nothing here claims to identify,/// is left as it was. An item with an id of its own keeps being matched by/// that, so one keyed by its data still keeps its nodes when items are-/// inserted ahead of it.+/// inserted ahead of it. `whole_pixel_height` is the list's+/// [`crate::ListState::with_whole_pixel_item_heights`].#[inline(always)]pub(crate) fn layout_as_list_item(element: &mut AnyElement,index: usize,available_space: Size<AvailableSpace>,+ whole_pixel_height: bool,window: &mut Window,cx: &mut App,) -> Size<Pixels> {let start = crate::fast::layers::lists::row_layout_start(window);- let size = crate::fast::layout::laying_out_list_row(window, |window| {+ let mut size = crate::fast::layout::laying_out_list_row(window, |window| {if element.0.fast_element_id().is_some() {return element.layout_as_root(available_space, window, cx);}@@ -293,5 +295,8 @@ pub(crate) fn layout_as_list_item(})});crate::fast::layers::lists::note_row_layout(window, index, start);+ if whole_pixel_height {+ size.height = size.height.round();+ }size}diff --git a/native/vendor/gpui-fast/crates/gpui/src/fast/list_measure.rs b/native/vendor/gpui-fast/crates/gpui/src/fast/list_measure.rsindex 8e64dc64e48..914ba3513e3 100644--- a/native/vendor/gpui-fast/crates/gpui/src/fast/list_measure.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/fast/list_measure.rs@@ -283,6 +283,7 @@ fn measure_deferred_items(&mut element,ix,available_item_space,+ state.whole_pixel_item_heights,window,cx,);@@ -372,6 +373,7 @@ fn resolve_pending_reveal(&mut element,item_ix,available_item_space,+ state.whole_pixel_item_heights,window,cx,);