Visual Studio Code, rebuilt in Rust
Rust
fix(workbench): draw a list again once its bounds are measured
rokartur09242a2af3d4
diff --git a/native/crates/app/src/workbench/list_scroll.rs b/native/crates/app/src/workbench/list_scroll.rsindex c499bd1516e..7cc8b729b68 100644--- a/native/crates/app/src/workbench/list_scroll.rs+++ b/native/crates/app/src/workbench/list_scroll.rs@@ -502,6 +502,11 @@ impl Workbench {(list_hitbox, tracks)},move |_, (list_hitbox, tracks), window, cx| {+ // The bars are laid out from the list's bounds of the frame before, and a list may prepaint after this+ // layer: one measured differently draws again.+ if scroller.bounds() != bounds || scroller.max_position() != max {+ super::part_view::redraw_after_frame(window, cx);+ }let view = window.current_view();workbench.update(cx, |workbench, _| workbench.list_scroll(list).view = Some(view));let mut sliders = Vec::new();diff --git a/native/crates/app/src/workbench/list_scroll/tests.rs b/native/crates/app/src/workbench/list_scroll/tests.rsindex 84596732380..1e4ff098a80 100644--- a/native/crates/app/src/workbench/list_scroll/tests.rs+++ b/native/crates/app/src/workbench/list_scroll/tests.rs@@ -238,3 +238,20 @@ fn the_views_and_pages_draw_their_bodies_in_a_scrollable(cx: &mut TestAppContext}std::fs::remove_dir_all(dir).unwrap();}++/// A list's scroll layer is laid out from the list's bounds of the frame before: a list drawn for the first time, as+/// Quick Open's, draws again once measured, so its wheel hitbox covers it and no stale frame stays on screen.+#[gpui::test]+fn a_list_drawn_for_the_first_time_draws_again_once_measured(cx: &mut TestAppContext) {+ let (dir, workbench, cx) = explorer("first-measure", cx);+ workbench.update_in(cx, |workbench, window, cx| workbench.open_file(dir.join("a.txt"), true, window, cx));+ cx.run_until_parked();+ for command in ["workbench.action.quickOpen", "workbench.action.showCommands", super::super::editor_status::CHANGE_INDENTATION] {+ run(&workbench, command, cx);+ assert!(workbench.read_with(cx, |workbench, _| workbench.quick_inputs.current().is_some()));+ assert_eq!(cx.update(|window, cx| window.retained_frame_difference(cx)), None, "{command}");+ cx.simulate_keystrokes("escape");+ cx.run_until_parked();+ }+ std::fs::remove_dir_all(dir).unwrap();+}diff --git a/native/crates/app/src/workbench/suggest_widget.rs b/native/crates/app/src/workbench/suggest_widget.rsindex a1716ece651..bbbdb27a8e1 100644--- a/native/crates/app/src/workbench/suggest_widget.rs+++ b/native/crates/app/src/workbench/suggest_widget.rs@@ -788,13 +788,25 @@ impl Workbench {let (top, focused) = (self.suggest.widget.top, self.suggest.widget.focused);let frozen = self.suggest_widget_frozen();let items: Vec<CompletionItem> = self.suggest_items().iter().skip(top).take(visible).cloned().collect();+ let list_bounds = self.suggest.widget.list_bounds.clone();+ // The list's scroll layer is laid out from these bounds: new ones draw again.+ let measure = canvas(+ move |bounds, window, cx| {+ if list_bounds.replace(bounds) != bounds {+ super::part_view::redraw_after_frame(window, cx);+ }+ },+ |_, _, _, _| {},+ )+ .absolute()+ .size_full();let mut list = div().id("suggest-list").relative().flex().flex_col().size_full()- .child(super::output_view::bounds_tracker(self.suggest.widget.list_bounds.clone()));+ .child(measure);let shown = items.len();for (offset, item) in items.into_iter().enumerate() {let index = top + offset;