From 1a23115773ac3466444256992f661ee31cbaace2 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 27 Nov 2025 01:03:42 +0800 Subject: [PATCH] gpui: Unify `track_scroll` method to receive a reference type (#43518) Release Notes: - N/A This PR to change the `track_scroll` method to receive a reference type like the [Div#track_scroll](https://docs.rs/gpui/latest/gpui/trait.StatefulInteractiveElement.html#method.track_scroll), [Div#track_focus](https://docs.rs/gpui/latest/gpui/trait.InteractiveElement.html#method.track_focus). ```diff - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx) + .vertical_scrollbar_for(&self.scroll_handle, window, cx) ``` https://github.com/zed-industries/zed/blob/56a2f9cfcf0c6a3c38f596b58002953763cd890f/crates/gpui/src/elements/div.rs#L1088-L1093 https://github.com/zed-industries/zed/blob/56a2f9cfcf0c6a3c38f596b58002953763cd890f/crates/gpui/src/elements/div.rs#L613-L620 --- crates/acp_tools/src/acp_tools.rs | 2 +- crates/agent_ui/src/acp/thread_history.rs | 8 ++------ crates/agent_ui/src/acp/thread_view.rs | 2 +- crates/agent_ui/src/agent_configuration.rs | 2 +- .../src/agent_configuration/add_llm_provider_modal.rs | 2 +- .../configure_context_server_modal.rs | 5 ++--- .../configure_context_server_tools_modal.rs | 2 +- .../debugger_ui/src/session/running/breakpoint_list.rs | 4 ++-- crates/debugger_ui/src/session/running/memory_view.rs | 4 ++-- crates/debugger_ui/src/session/running/module_list.rs | 4 ++-- .../src/session/running/stack_frame_list.rs | 2 +- .../debugger_ui/src/session/running/variable_list.rs | 6 +++--- crates/editor/src/code_context_menus.rs | 6 +++--- crates/editor/src/hover_popover.rs | 4 ++-- crates/editor/src/signature_help.rs | 2 +- crates/extensions_ui/src/extensions_ui.rs | 4 ++-- crates/git_ui/src/git_panel.rs | 4 ++-- crates/gpui/examples/data_table.rs | 2 +- crates/gpui/src/elements/uniform_list.rs | 6 +++--- crates/language_tools/src/syntax_tree_view.rs | 4 ++-- crates/markdown/src/markdown.rs | 2 +- crates/markdown_preview/src/markdown_preview_view.rs | 2 +- crates/miniprofiler_ui/src/miniprofiler_ui.rs | 4 ++-- crates/onboarding/src/onboarding.rs | 2 +- crates/outline_panel/src/outline_panel.rs | 4 ++-- crates/picker/src/picker.rs | 6 +++--- crates/project_panel/src/project_panel.rs | 4 ++-- crates/recent_projects/src/remote_servers.rs | 2 +- crates/settings_ui/src/settings_ui.rs | 8 ++++---- crates/terminal_view/src/terminal_view.rs | 2 +- crates/ui/src/components/data_table.rs | 4 ++-- crates/ui/src/components/scrollbar.rs | 10 +++++----- crates/ui/src/components/tab_bar.rs | 4 ++-- crates/zed/src/zed/component_preview.rs | 2 +- 34 files changed, 63 insertions(+), 68 deletions(-) diff --git a/crates/acp_tools/src/acp_tools.rs b/crates/acp_tools/src/acp_tools.rs index 7615784676c7d9ff1782a6e9537e608cb927154d..0905effce38d1bfd4fa18e1d00169d6c7ef6c2d7 100644 --- a/crates/acp_tools/src/acp_tools.rs +++ b/crates/acp_tools/src/acp_tools.rs @@ -528,7 +528,7 @@ impl Render for AcpTools { .with_sizing_behavior(gpui::ListSizingBehavior::Auto) .size_full(), ) - .vertical_scrollbar_for(connection.list_state.clone(), window, cx) + .vertical_scrollbar_for(&connection.list_state, window, cx) .into_any() } } diff --git a/crates/agent_ui/src/acp/thread_history.rs b/crates/agent_ui/src/acp/thread_history.rs index 29759093303a684fdfd9ad255d269516ed7a29b9..e5c83d48f1fd4633591441ad88076e66d3eb1e62 100644 --- a/crates/agent_ui/src/acp/thread_history.rs +++ b/crates/agent_ui/src/acp/thread_history.rs @@ -527,14 +527,10 @@ impl Render for AcpThreadHistory { ) .p_1() .pr_4() - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .flex_grow(), ) - .vertical_scrollbar_for( - self.scroll_handle.clone(), - window, - cx, - ) + .vertical_scrollbar_for(&self.scroll_handle, window, cx) } }) .when(!has_no_history, |this| { diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 45b15e6e9e3eaa03fc69912eab3e778335b714d4..a2929ad23ba8558b61abbf1d25ffe3843a918c2e 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -5896,7 +5896,7 @@ impl Render for AcpThreadView { .flex_grow() .into_any(), ) - .vertical_scrollbar_for(self.list_state.clone(), window, cx) + .vertical_scrollbar_for(&self.list_state, window, cx) .into_any() } else { this.child(self.render_recent_history(cx)).into_any() diff --git a/crates/agent_ui/src/agent_configuration.rs b/crates/agent_ui/src/agent_configuration.rs index ef6b90ad89e2e038e96d8864d4c2ce0ecf333d6e..f831329e2cde40dbb9d4b9e882d6bc942f383422 100644 --- a/crates/agent_ui/src/agent_configuration.rs +++ b/crates/agent_ui/src/agent_configuration.rs @@ -1209,7 +1209,7 @@ impl Render for AgentConfiguration { .child(self.render_context_servers_section(window, cx)) .child(self.render_provider_configuration_section(cx)), ) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx), + .vertical_scrollbar_for(&self.scroll_handle, window, cx), ) } } diff --git a/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs b/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs index 3427dab0d22c6900a3078f1dcb4cc7e892cce7db..02269511bb9a4d9b95fe27b66e3ca0a9e5c498c5 100644 --- a/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs +++ b/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs @@ -516,7 +516,7 @@ impl Render for AddLlmProviderModal { .child( div() .size_full() - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx) + .vertical_scrollbar_for(&self.scroll_handle, window, cx) .child( v_flex() .id("modal_content") diff --git a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs index a93df3839d98d95e2f91833078dbe96bc3fb8889..85f527ff5a1262aa36657316d86999ac617fb09d 100644 --- a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs +++ b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs @@ -821,7 +821,6 @@ impl ConfigureContextServerModal { impl Render for ConfigureContextServerModal { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { - let scroll_handle = self.scroll_handle.clone(); div() .elevation_3(cx) .w(rems(34.)) @@ -849,7 +848,7 @@ impl Render for ConfigureContextServerModal { .id("modal-content") .max_h(vh(0.7, window)) .overflow_y_scroll() - .track_scroll(&scroll_handle) + .track_scroll(&self.scroll_handle) .child(self.render_modal_description(window, cx)) .child(self.render_modal_content(cx)) .child(match &self.state { @@ -862,7 +861,7 @@ impl Render for ConfigureContextServerModal { } }), ) - .vertical_scrollbar_for(scroll_handle, window, cx), + .vertical_scrollbar_for(&self.scroll_handle, window, cx), ), ) .footer(self.render_modal_footer(cx)), diff --git a/crates/agent_ui/src/agent_configuration/configure_context_server_tools_modal.rs b/crates/agent_ui/src/agent_configuration/configure_context_server_tools_modal.rs index 3fe0b8d1b1400b4362192261995ed5b6bd1cb662..3573c8b67ee81ef9cd1decacefb52017dabdb178 100644 --- a/crates/agent_ui/src/agent_configuration/configure_context_server_tools_modal.rs +++ b/crates/agent_ui/src/agent_configuration/configure_context_server_tools_modal.rs @@ -138,7 +138,7 @@ impl ConfigureContextServerToolsModal { items })), ) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx) + .vertical_scrollbar_for(&self.scroll_handle, window, cx) .into_any_element() } } diff --git a/crates/debugger_ui/src/session/running/breakpoint_list.rs b/crates/debugger_ui/src/session/running/breakpoint_list.rs index ca50f67c9236d19a9f04f327091eb383ab72e122..2c7e2074678290356b7669228dcf29008f1cc36b 100644 --- a/crates/debugger_ui/src/session/running/breakpoint_list.rs +++ b/crates/debugger_ui/src/session/running/breakpoint_list.rs @@ -575,7 +575,7 @@ impl BreakpointList { ) .with_horizontal_sizing_behavior(gpui::ListHorizontalSizingBehavior::Unconstrained) .with_width_from_item(self.max_width_index) - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .flex_1() } @@ -776,7 +776,7 @@ impl Render for BreakpointList { .child(self.render_list(cx)) .custom_scrollbars( ui::Scrollbars::new(ScrollAxes::Both) - .tracked_scroll_handle(self.scroll_handle.clone()) + .tracked_scroll_handle(&self.scroll_handle) .with_track_along(ScrollAxes::Both, cx.theme().colors().panel_background) .tracked_entity(cx.entity_id()), window, diff --git a/crates/debugger_ui/src/session/running/memory_view.rs b/crates/debugger_ui/src/session/running/memory_view.rs index 8670beb0f5f93f68a6052b868a866e22b82c92fd..55a8e8429eb23cd0bfcaa7d592d16797c061d2ae 100644 --- a/crates/debugger_ui/src/session/running/memory_view.rs +++ b/crates/debugger_ui/src/session/running/memory_view.rs @@ -229,7 +229,7 @@ impl MemoryView { rows }, ) - .track_scroll(view_state.scroll_handle) + .track_scroll(&view_state.scroll_handle) .with_horizontal_sizing_behavior(ListHorizontalSizingBehavior::Unconstrained) .on_scroll_wheel(cx.listener(|this, evt: &ScrollWheelEvent, window, _| { let mut view_state = this.view_state(); @@ -921,7 +921,7 @@ impl Render for MemoryView { })) .custom_scrollbars( ui::Scrollbars::new(ui::ScrollAxes::Both) - .tracked_scroll_handle(self.view_state_handle.clone()) + .tracked_scroll_handle(&self.view_state_handle) .with_track_along( ui::ScrollAxes::Both, cx.theme().colors().panel_background, diff --git a/crates/debugger_ui/src/session/running/module_list.rs b/crates/debugger_ui/src/session/running/module_list.rs index 545d8392745c636b805cfc1e0743170635ef8abe..19f407eb23f8acf0aa665f5119ecfd2156eb685f 100644 --- a/crates/debugger_ui/src/session/running/module_list.rs +++ b/crates/debugger_ui/src/session/running/module_list.rs @@ -253,7 +253,7 @@ impl ModuleList { range.map(|ix| this.render_entry(ix, cx)).collect() }), ) - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .size_full() } } @@ -279,6 +279,6 @@ impl Render for ModuleList { .size_full() .p_1() .child(self.render_list(window, cx)) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx) + .vertical_scrollbar_for(&self.scroll_handle, window, cx) } } diff --git a/crates/debugger_ui/src/session/running/stack_frame_list.rs b/crates/debugger_ui/src/session/running/stack_frame_list.rs index a8fabd327a3de630ff884899fe7af1167932618c..96a910af4dd0ac901c6802c139ddd5b8b3d728bc 100644 --- a/crates/debugger_ui/src/session/running/stack_frame_list.rs +++ b/crates/debugger_ui/src/session/running/stack_frame_list.rs @@ -913,7 +913,7 @@ impl Render for StackFrameList { ) }) .child(self.render_list(window, cx)) - .vertical_scrollbar_for(self.list_state.clone(), window, cx) + .vertical_scrollbar_for(&self.list_state, window, cx) } } diff --git a/crates/debugger_ui/src/session/running/variable_list.rs b/crates/debugger_ui/src/session/running/variable_list.rs index 7d736aace58ab1b27ccab5690cf24d4cff9a47f6..1b455b59d7d12712a3d4adc713a6ed15e8166c6e 100644 --- a/crates/debugger_ui/src/session/running/variable_list.rs +++ b/crates/debugger_ui/src/session/running/variable_list.rs @@ -1557,7 +1557,7 @@ impl Render for VariableList { this.render_entries(range, window, cx) }), ) - .track_scroll(self.list_handle.clone()) + .track_scroll(&self.list_handle) .with_width_from_item(self.max_width_index) .with_sizing_behavior(gpui::ListSizingBehavior::Auto) .with_horizontal_sizing_behavior(gpui::ListHorizontalSizingBehavior::Unconstrained) @@ -1574,10 +1574,10 @@ impl Render for VariableList { ) .with_priority(1) })) - // .vertical_scrollbar_for(self.list_handle.clone(), window, cx) + // .vertical_scrollbar_for(&self.list_handle, window, cx) .custom_scrollbars( ui::Scrollbars::new(ScrollAxes::Both) - .tracked_scroll_handle(self.list_handle.clone()) + .tracked_scroll_handle(&self.list_handle) .with_track_along(ScrollAxes::Both, cx.theme().colors().panel_background) .tracked_entity(cx.entity_id()), window, diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index 9a2b8c385689f284fc42e49a5c7451b3774fe018..6a07d39210773476b5f88764c5a21f292da48676 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -933,7 +933,7 @@ impl CompletionsMenu { ) .occlude() .max_h(max_height_in_lines as f32 * window.line_height()) - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .with_sizing_behavior(ListSizingBehavior::Infer) .map(|this| { if self.display_options.dynamic_width { @@ -948,7 +948,7 @@ impl CompletionsMenu { div().child(list).custom_scrollbars( Scrollbars::for_settings::() .show_along(ScrollAxes::Vertical) - .tracked_scroll_handle(self.scroll_handle.clone()), + .tracked_scroll_handle(&self.scroll_handle), window, cx, ), @@ -1599,7 +1599,7 @@ impl CodeActionsMenu { ) .occlude() .max_h(max_height_in_lines as f32 * window.line_height()) - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .with_width_from_item( self.actions .iter() diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 5f831341bab2a4e37410a1e3e168bcf72bba93a8..0b9a25d3ee0fcb1cb67497bf51fe41ed73a3692e 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -914,7 +914,7 @@ impl InfoPopover { ) .custom_scrollbars( Scrollbars::for_settings::() - .tracked_scroll_handle(self.scroll_handle.clone()), + .tracked_scroll_handle(&self.scroll_handle), window, cx, ) @@ -1012,7 +1012,7 @@ impl DiagnosticPopover { ) .custom_scrollbars( Scrollbars::for_settings::() - .tracked_scroll_handle(self.scroll_handle.clone()), + .tracked_scroll_handle(&self.scroll_handle), window, cx, ), diff --git a/crates/editor/src/signature_help.rs b/crates/editor/src/signature_help.rs index b394364e01cbd647a0e17afc0ddc13afdb12ced3..2554db2450103709275b3f7946076fd891326d84 100644 --- a/crates/editor/src/signature_help.rs +++ b/crates/editor/src/signature_help.rs @@ -391,7 +391,7 @@ impl SignatureHelpPopover { ) }), ) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx); + .vertical_scrollbar_for(&self.scroll_handle, window, cx); let controls = if self.signatures.len() > 1 { let prev_button = IconButton::new("signature_help_prev", IconName::ChevronUp) diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rs index e35c90b6104b44bd6dbf3fe86aeaf84f122c04ca..e6d30527e0d7672255bf8f61cfd56fe06b409920 100644 --- a/crates/extensions_ui/src/extensions_ui.rs +++ b/crates/extensions_ui/src/extensions_ui.rs @@ -1704,12 +1704,12 @@ impl Render for ExtensionsPage { if count == 0 { this.child(self.render_empty_state(cx)).into_any_element() } else { - let scroll_handle = self.list.clone(); + let scroll_handle = &self.list; this.child( uniform_list("entries", count, cx.processor(Self::render_extensions)) .flex_grow() .pb_4() - .track_scroll(scroll_handle.clone()), + .track_scroll(scroll_handle), ) .vertical_scrollbar_for(scroll_handle, window, cx) .into_any_element() diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 1f66d194477c64fef207e63d4c87ad4d76675f65..cf6babb401b6f407506595f3dd95592e98c18286 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -3939,7 +3939,7 @@ impl GitPanel { ListHorizontalSizingBehavior::Unconstrained, ) .with_width_from_item(self.max_width_item_index) - .track_scroll(self.scroll_handle.clone()), + .track_scroll(&self.scroll_handle), ) .on_mouse_down( MouseButton::Right, @@ -3949,7 +3949,7 @@ impl GitPanel { ) .custom_scrollbars( Scrollbars::for_settings::() - .tracked_scroll_handle(self.scroll_handle.clone()) + .tracked_scroll_handle(&self.scroll_handle) .with_track_along( ScrollAxes::Horizontal, cx.theme().colors().panel_background, diff --git a/crates/gpui/examples/data_table.rs b/crates/gpui/examples/data_table.rs index 56c9625ed3039b872cf4fcc70e84719ce903e268..dd1a443a9dfaa28a5079a034b8214ce1bbf01da8 100644 --- a/crates/gpui/examples/data_table.rs +++ b/crates/gpui/examples/data_table.rs @@ -438,7 +438,7 @@ impl Render for DataTable { }), ) .size_full() - .track_scroll(self.scroll_handle.clone()), + .track_scroll(&self.scroll_handle), ) .child(self.render_scrollbar(window, cx)), ), diff --git a/crates/gpui/src/elements/uniform_list.rs b/crates/gpui/src/elements/uniform_list.rs index 72843ea6330aaa24d9e1d6bf34d024cdeb54ad4a..1e38b0e7ac9abcf891201b7db61b819abe00ef1e 100644 --- a/crates/gpui/src/elements/uniform_list.rs +++ b/crates/gpui/src/elements/uniform_list.rs @@ -668,9 +668,9 @@ impl UniformList { } /// Track and render scroll state of this list with reference to the given scroll handle. - pub fn track_scroll(mut self, handle: UniformListScrollHandle) -> Self { + pub fn track_scroll(mut self, handle: &UniformListScrollHandle) -> Self { self.interactivity.tracked_scroll_handle = Some(handle.0.borrow().base_handle.clone()); - self.scroll_handle = Some(handle); + self.scroll_handle = Some(handle.clone()); self } @@ -780,7 +780,7 @@ mod test { .collect() }), ) - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .h(px(200.0)), ) } diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 885f6bed327c765019ae166e21eab112f884e7dd..3ac007c134657ff33259f961f170d5a7d732a22c 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -507,11 +507,11 @@ impl Render for SyntaxTreeView { }), ) .size_full() - .track_scroll(self.list_scroll_handle.clone()) + .track_scroll(&self.list_scroll_handle) .text_bg(cx.theme().colors().background) .into_any_element(), ) - .vertical_scrollbar_for(self.list_scroll_handle.clone(), window, cx) + .vertical_scrollbar_for(&self.list_scroll_handle, window, cx) .into_any_element() } else { let inner_content = v_flex() diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 1de6d494ffbf445ca8ee3df9d1e83b5575f8224e..dd0d726734173591cb9ed9f8cc965d06aaee7e89 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -889,7 +889,7 @@ impl Element for MarkdownElement { { let scrollbars = Scrollbars::new(ScrollAxes::Horizontal) .id(("markdown-code-block-scrollbar", range.start)) - .tracked_scroll_handle(scroll_handle.clone()) + .tracked_scroll_handle(scroll_handle) .with_track_along( ScrollAxes::Horizontal, cx.theme().colors().editor_background, diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs index c4d3c033df6395235603837bf0944eeb59d3dfbc..4126a31379fa74a750a7d111ac71dc180a3bb0ff 100644 --- a/crates/markdown_preview/src/markdown_preview_view.rs +++ b/crates/markdown_preview/src/markdown_preview_view.rs @@ -611,6 +611,6 @@ impl Render for MarkdownPreviewView { .size_full(), ) })) - .vertical_scrollbar_for(self.list_state.clone(), window, cx) + .vertical_scrollbar_for(&self.list_state, window, cx) } } diff --git a/crates/miniprofiler_ui/src/miniprofiler_ui.rs b/crates/miniprofiler_ui/src/miniprofiler_ui.rs index 93ccfc559c6eedc5e1be1c3ca68355aeba878a76..ea59b43cc1dbc2cb1b8476b00d8fa7d07636afec 100644 --- a/crates/miniprofiler_ui/src/miniprofiler_ui.rs +++ b/crates/miniprofiler_ui/src/miniprofiler_ui.rs @@ -400,10 +400,10 @@ impl Render for ProfilerWindow { this.autoscroll = false; cx.notify(); })) - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .size_full(), ) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx), + .vertical_scrollbar_for(&self.scroll_handle, window, cx), ) }) } diff --git a/crates/onboarding/src/onboarding.rs b/crates/onboarding/src/onboarding.rs index 404af2c74f9524aa1d52db39de2354bbe4564240..94581e142339cde9d4f1f01a3fb361ae810c1efa 100644 --- a/crates/onboarding/src/onboarding.rs +++ b/crates/onboarding/src/onboarding.rs @@ -350,7 +350,7 @@ impl Render for Onboarding { .child(self.render_page(cx)) .track_scroll(&self.scroll_handle), ) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx), + .vertical_scrollbar_for(&self.scroll_handle, window, cx), ) } } diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 1e649b2eb64fda970f845e9376be3f61944dde85..6e78b8a1e1f573d9870d42c6a5e99c8574e6979a 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -4639,7 +4639,7 @@ impl OutlinePanel { .with_sizing_behavior(ListSizingBehavior::Infer) .with_horizontal_sizing_behavior(ListHorizontalSizingBehavior::Unconstrained) .with_width_from_item(self.max_width_item_index) - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) .when(show_indent_guides, |list| { list.with_decoration( ui::indent_guides(px(indent_size), IndentGuideColors::panel(cx)) @@ -4692,7 +4692,7 @@ impl OutlinePanel { .child(list_contents.size_full().flex_shrink()) .custom_scrollbars( Scrollbars::for_settings::() - .tracked_scroll_handle(self.scroll_handle.clone()) + .tracked_scroll_handle(&self.scroll_handle.clone()) .with_track_along( ScrollAxes::Horizontal, cx.theme().colors().panel_background, diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index 4e7dba59ad39399b9edab30f553bdc17545540dd..8fb4941b716efa8186937ec7b49bcc3cfb26d44b 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -780,7 +780,7 @@ impl Picker { }) .flex_grow() .py_1() - .track_scroll(scroll_handle.clone()) + .track_scroll(&scroll_handle) .into_any_element(), ElementContainer::List(state) => list( state.clone(), @@ -866,12 +866,12 @@ impl Render for Picker { this.map(|this| match &self.element_container { ElementContainer::List(state) => this.custom_scrollbars( - base_scrollbar_config.tracked_scroll_handle(state.clone()), + base_scrollbar_config.tracked_scroll_handle(state), window, cx, ), ElementContainer::UniformList(state) => this.custom_scrollbars( - base_scrollbar_config.tracked_scroll_handle(state.clone()), + base_scrollbar_config.tracked_scroll_handle(state), window, cx, ), diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index cde0b89bb9115476744ed606f16174039db62cf6..e9af8bbe3fff1f5ff7d910b6aa16e05090351777 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -5765,7 +5765,7 @@ impl Render for ProjectPanel { ListHorizontalSizingBehavior::Unconstrained, ) .with_width_from_item(self.state.max_width_item_index) - .track_scroll(self.scroll_handle.clone()), + .track_scroll(&self.scroll_handle), ) .child( div() @@ -5908,7 +5908,7 @@ impl Render for ProjectPanel { ) .custom_scrollbars( Scrollbars::for_settings::() - .tracked_scroll_handle(self.scroll_handle.clone()) + .tracked_scroll_handle(&self.scroll_handle) .with_track_along( ScrollAxes::Horizontal, cx.theme().colors().panel_background, diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index 76b0b230dc16b5d5e594379bb94b30ca66b9b317..6dff231b30ddde741f69ba9d4e0366517d8e2751 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -2160,7 +2160,7 @@ impl RemoteServerProjects { ) .size_full(), ) - .vertical_scrollbar_for(state.scroll_handle, window, cx), + .vertical_scrollbar_for(&state.scroll_handle, window, cx), ), ) .into_any_element() diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 499d6b04653b06c41ef4e302cfd4b4e77efc95c9..2726e1cbd6da7b568d3412791826bc1f7b826397 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -2455,9 +2455,9 @@ impl SettingsWindow { }), ) .size_full() - .track_scroll(self.navbar_scroll_handle.clone()), + .track_scroll(&self.navbar_scroll_handle), ) - .vertical_scrollbar_for(self.navbar_scroll_handle.clone(), window, cx), + .vertical_scrollbar_for(&self.navbar_scroll_handle, window, cx), ) .child( h_flex() @@ -3012,10 +3012,10 @@ impl SettingsWindow { window.focus_prev(); })) .when(sub_page_stack().is_empty(), |this| { - this.vertical_scrollbar_for(self.list_state.clone(), window, cx) + this.vertical_scrollbar_for(&self.list_state, window, cx) }) .when(!sub_page_stack().is_empty(), |this| { - this.vertical_scrollbar_for(self.sub_page_scroll_handle.clone(), window, cx) + this.vertical_scrollbar_for(&self.sub_page_scroll_handle, window, cx) }) .track_focus(&self.content_focus_handle.focus_handle(cx)) .pt_6() diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 7b3e29ac9b0582d081a286539d973fe8f1a453c5..64336886a4b430f780db1126b8d677e51cff066b 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -1118,7 +1118,7 @@ impl Render for TerminalView { ScrollAxes::Vertical, cx.theme().colors().editor_background, ) - .tracked_scroll_handle(self.scroll_handle.clone()), + .tracked_scroll_handle(&self.scroll_handle), window, cx, ) diff --git a/crates/ui/src/components/data_table.rs b/crates/ui/src/components/data_table.rs index a505281cf3fa9868a19a04c168d0b1b5c71a4f85..f7cce2b85ffa3aeb9f97634c6c0fa65c46f4a8e7 100644 --- a/crates/ui/src/components/data_table.rs +++ b/crates/ui/src/components/data_table.rs @@ -872,7 +872,7 @@ impl RenderOnce for Table { interaction_state.as_ref(), |this, state| { this.track_scroll( - state.read_with(cx, |s, _| s.scroll_handle.clone()), + &state.read_with(cx, |s, _| s.scroll_handle.clone()), ) }, ), @@ -906,7 +906,7 @@ impl RenderOnce for Table { .unwrap_or_else(|| Scrollbars::new(super::ScrollAxes::Both)); content .custom_scrollbars( - scrollbars.tracked_scroll_handle(state.read(cx).scroll_handle.clone()), + scrollbars.tracked_scroll_handle(&state.read(cx).scroll_handle), window, cx, ) diff --git a/crates/ui/src/components/scrollbar.rs b/crates/ui/src/components/scrollbar.rs index d3d33a296bbd65edb24371d8f5f1e6462e77e3fe..391d480fb313d078bb20ab790ecbb61d7425257a 100644 --- a/crates/ui/src/components/scrollbar.rs +++ b/crates/ui/src/components/scrollbar.rs @@ -150,9 +150,9 @@ pub trait WithScrollbar: Sized { // } #[track_caller] - fn vertical_scrollbar_for( + fn vertical_scrollbar_for( self, - scroll_handle: ScrollHandle, + scroll_handle: &ScrollHandle, window: &mut Window, cx: &mut App, ) -> Self::Output { @@ -441,7 +441,7 @@ impl Scrollbars { pub fn tracked_scroll_handle( self, - tracked_scroll_handle: TrackedHandle, + tracked_scroll_handle: &TrackedHandle, ) -> Scrollbars { let Self { id, @@ -454,7 +454,7 @@ impl Scrollbars { } = self; Scrollbars { - scrollable_handle: Handle::Tracked(tracked_scroll_handle), + scrollable_handle: Handle::Tracked(tracked_scroll_handle.clone()), id, tracked_entity: tracked_entity_id, visibility, @@ -968,7 +968,7 @@ impl ScrollableHandle for ScrollHandle { } } -pub trait ScrollableHandle: 'static + Any + Sized { +pub trait ScrollableHandle: 'static + Any + Sized + Clone { fn max_offset(&self) -> Size; fn set_offset(&self, point: Point); fn offset(&self) -> Point; diff --git a/crates/ui/src/components/tab_bar.rs b/crates/ui/src/components/tab_bar.rs index 3c467c06ce2654c5886c30e42dfb7276fdb7d289..5d41466e3caadf6697b3c1681a405dafa2fb3101 100644 --- a/crates/ui/src/components/tab_bar.rs +++ b/crates/ui/src/components/tab_bar.rs @@ -24,8 +24,8 @@ impl TabBar { } } - pub fn track_scroll(mut self, scroll_handle: ScrollHandle) -> Self { - self.scroll_handle = Some(scroll_handle); + pub fn track_scroll(mut self, scroll_handle: &ScrollHandle) -> Self { + self.scroll_handle = Some(scroll_handle.clone()); self } diff --git a/crates/zed/src/zed/component_preview.rs b/crates/zed/src/zed/component_preview.rs index 18279d8ee88821d44166fb5aedebca2e51ae9491..c231836aaa9219cab2ed913db70ad1704606dfd1 100644 --- a/crates/zed/src/zed/component_preview.rs +++ b/crates/zed/src/zed/component_preview.rs @@ -627,7 +627,7 @@ impl Render for ComponentPreview { .collect() }), ) - .track_scroll(self.nav_scroll_handle.clone()) + .track_scroll(&self.nav_scroll_handle) .p_2p5() .w(px(231.)) // Matches perfectly with the size of the "Component Preview" tab, if that's the first one in the pane .h_full()