From 83c871210fc5c1d9f7da3a4af5f21b73f5b30164 Mon Sep 17 00:00:00 2001 From: dino Date: Wed, 17 Dec 2025 12:31:42 +0000 Subject: [PATCH] fix(settings_ui): fix scrollbar breaking when ui font size changes When the UI font size changes, the settings window's scrollbar would break because list item measurements were cached and not invalidated. We're using `ListState.measure_all()` to pre-measure all items for an accurate scrollbar. When font size changes, these cached measurements become stale but weren't being refreshed. This commit fixes the issue by calling `ListState.measure_all()` when settings change, ensuring items are re-measured on the next layout without affecting scroll position. Closes #43683 --- crates/settings_ui/src/settings_ui.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 40678f6cf8d1c6773ccf1168e065cb318ae9f14f..f1316de125485b1a69ea6ae22c2b3506cb289e51 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -1378,6 +1378,14 @@ impl SettingsWindow { cx.observe_global_in::(window, move |this, window, cx| { this.fetch_files(window, cx); + + // Whenever settings are changed, it's possible that the changed + // settings affects the rendering of the `SettingsWindow`, like is + // the case with `ui_font_size`. When that happens, we need to + // instruct the `ListState` to re-measure the list items, as the + // list item heights may have changed depending on the new font + // size. + this.list_state.clone().measure_all(); cx.notify(); }) .detach(); @@ -1487,7 +1495,6 @@ impl SettingsWindow { None }; - // high overdraw value so the list scrollbar len doesn't change too much let list_state = gpui::ListState::new(0, gpui::ListAlignment::Top, px(0.0)).measure_all(); list_state.set_scroll_handler(|_, _, _| {}); @@ -1980,7 +1987,6 @@ impl SettingsWindow { } fn reset_list_state(&mut self) { - // plus one for the title let mut visible_items_count = self.visible_page_items().count(); if visible_items_count > 0 {