Skip to content

Commit 1a23115

Browse files
authored
gpui: Unify track_scroll method to receive a reference type (zed-industries#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
1 parent 757c043 commit 1a23115

File tree

34 files changed

+63
-68
lines changed

34 files changed

+63
-68
lines changed

crates/acp_tools/src/acp_tools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl Render for AcpTools {
528528
.with_sizing_behavior(gpui::ListSizingBehavior::Auto)
529529
.size_full(),
530530
)
531-
.vertical_scrollbar_for(connection.list_state.clone(), window, cx)
531+
.vertical_scrollbar_for(&connection.list_state, window, cx)
532532
.into_any()
533533
}
534534
}

crates/agent_ui/src/acp/thread_history.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,10 @@ impl Render for AcpThreadHistory {
527527
)
528528
.p_1()
529529
.pr_4()
530-
.track_scroll(self.scroll_handle.clone())
530+
.track_scroll(&self.scroll_handle)
531531
.flex_grow(),
532532
)
533-
.vertical_scrollbar_for(
534-
self.scroll_handle.clone(),
535-
window,
536-
cx,
537-
)
533+
.vertical_scrollbar_for(&self.scroll_handle, window, cx)
538534
}
539535
})
540536
.when(!has_no_history, |this| {

crates/agent_ui/src/acp/thread_view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5896,7 +5896,7 @@ impl Render for AcpThreadView {
58965896
.flex_grow()
58975897
.into_any(),
58985898
)
5899-
.vertical_scrollbar_for(self.list_state.clone(), window, cx)
5899+
.vertical_scrollbar_for(&self.list_state, window, cx)
59005900
.into_any()
59015901
} else {
59025902
this.child(self.render_recent_history(cx)).into_any()

crates/agent_ui/src/agent_configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ impl Render for AgentConfiguration {
12091209
.child(self.render_context_servers_section(window, cx))
12101210
.child(self.render_provider_configuration_section(cx)),
12111211
)
1212-
.vertical_scrollbar_for(self.scroll_handle.clone(), window, cx),
1212+
.vertical_scrollbar_for(&self.scroll_handle, window, cx),
12131213
)
12141214
}
12151215
}

crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl Render for AddLlmProviderModal {
516516
.child(
517517
div()
518518
.size_full()
519-
.vertical_scrollbar_for(self.scroll_handle.clone(), window, cx)
519+
.vertical_scrollbar_for(&self.scroll_handle, window, cx)
520520
.child(
521521
v_flex()
522522
.id("modal_content")

crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,6 @@ impl ConfigureContextServerModal {
821821

822822
impl Render for ConfigureContextServerModal {
823823
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
824-
let scroll_handle = self.scroll_handle.clone();
825824
div()
826825
.elevation_3(cx)
827826
.w(rems(34.))
@@ -849,7 +848,7 @@ impl Render for ConfigureContextServerModal {
849848
.id("modal-content")
850849
.max_h(vh(0.7, window))
851850
.overflow_y_scroll()
852-
.track_scroll(&scroll_handle)
851+
.track_scroll(&self.scroll_handle)
853852
.child(self.render_modal_description(window, cx))
854853
.child(self.render_modal_content(cx))
855854
.child(match &self.state {
@@ -862,7 +861,7 @@ impl Render for ConfigureContextServerModal {
862861
}
863862
}),
864863
)
865-
.vertical_scrollbar_for(scroll_handle, window, cx),
864+
.vertical_scrollbar_for(&self.scroll_handle, window, cx),
866865
),
867866
)
868867
.footer(self.render_modal_footer(cx)),

crates/agent_ui/src/agent_configuration/configure_context_server_tools_modal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl ConfigureContextServerToolsModal {
138138
items
139139
})),
140140
)
141-
.vertical_scrollbar_for(self.scroll_handle.clone(), window, cx)
141+
.vertical_scrollbar_for(&self.scroll_handle, window, cx)
142142
.into_any_element()
143143
}
144144
}

crates/debugger_ui/src/session/running/breakpoint_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ impl BreakpointList {
575575
)
576576
.with_horizontal_sizing_behavior(gpui::ListHorizontalSizingBehavior::Unconstrained)
577577
.with_width_from_item(self.max_width_index)
578-
.track_scroll(self.scroll_handle.clone())
578+
.track_scroll(&self.scroll_handle)
579579
.flex_1()
580580
}
581581

@@ -776,7 +776,7 @@ impl Render for BreakpointList {
776776
.child(self.render_list(cx))
777777
.custom_scrollbars(
778778
ui::Scrollbars::new(ScrollAxes::Both)
779-
.tracked_scroll_handle(self.scroll_handle.clone())
779+
.tracked_scroll_handle(&self.scroll_handle)
780780
.with_track_along(ScrollAxes::Both, cx.theme().colors().panel_background)
781781
.tracked_entity(cx.entity_id()),
782782
window,

crates/debugger_ui/src/session/running/memory_view.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl MemoryView {
229229
rows
230230
},
231231
)
232-
.track_scroll(view_state.scroll_handle)
232+
.track_scroll(&view_state.scroll_handle)
233233
.with_horizontal_sizing_behavior(ListHorizontalSizingBehavior::Unconstrained)
234234
.on_scroll_wheel(cx.listener(|this, evt: &ScrollWheelEvent, window, _| {
235235
let mut view_state = this.view_state();
@@ -921,7 +921,7 @@ impl Render for MemoryView {
921921
}))
922922
.custom_scrollbars(
923923
ui::Scrollbars::new(ui::ScrollAxes::Both)
924-
.tracked_scroll_handle(self.view_state_handle.clone())
924+
.tracked_scroll_handle(&self.view_state_handle)
925925
.with_track_along(
926926
ui::ScrollAxes::Both,
927927
cx.theme().colors().panel_background,

crates/debugger_ui/src/session/running/module_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl ModuleList {
253253
range.map(|ix| this.render_entry(ix, cx)).collect()
254254
}),
255255
)
256-
.track_scroll(self.scroll_handle.clone())
256+
.track_scroll(&self.scroll_handle)
257257
.size_full()
258258
}
259259
}
@@ -279,6 +279,6 @@ impl Render for ModuleList {
279279
.size_full()
280280
.p_1()
281281
.child(self.render_list(window, cx))
282-
.vertical_scrollbar_for(self.scroll_handle.clone(), window, cx)
282+
.vertical_scrollbar_for(&self.scroll_handle, window, cx)
283283
}
284284
}

0 commit comments

Comments
 (0)