Use new div impl to reduce footprint

This commit is contained in:
MrSubidubi 2025-08-13 12:18:47 +02:00
parent c28d873a2f
commit bfd71db0a3
13 changed files with 45 additions and 52 deletions

View file

@ -2633,38 +2633,36 @@ impl Render for AcpThreadView {
v_flex().flex_1().map(|this| { v_flex().flex_1().map(|this| {
if self.list_state.item_count() > 0 { if self.list_state.item_count() > 0 {
this.id("acp-thread-list-view") this.child(
.child( list(
list( self.list_state.clone(),
self.list_state.clone(), cx.processor(|this, index: usize, window, cx| {
cx.processor(|this, index: usize, window, cx| { let Some((entry, len)) = this.thread().and_then(|thread| {
let Some((entry, len)) = let entries = &thread.read(cx).entries();
this.thread().and_then(|thread| { Some((entries.get(index)?, entries.len()))
let entries = &thread.read(cx).entries(); }) else {
Some((entries.get(index)?, entries.len())) return Empty.into_any();
}) };
else { this.render_entry(index, len, entry, window, cx)
return Empty.into_any(); }),
};
this.render_entry(index, len, entry, window, cx)
}),
)
.with_sizing_behavior(gpui::ListSizingBehavior::Auto)
.flex_grow()
.into_any(),
) )
.vertical_scrollbar(window, cx) .with_sizing_behavior(gpui::ListSizingBehavior::Auto)
.children(match thread_clone.read(cx).status() { .flex_grow()
ThreadStatus::Idle .into_any(),
| ThreadStatus::WaitingForToolConfirmation => None, )
ThreadStatus::Generating => div() .vertical_scrollbar(window, cx)
.px_5() .children(match thread_clone.read(cx).status() {
.py_2() ThreadStatus::Idle | ThreadStatus::WaitingForToolConfirmation => {
.child(LoadingLabel::new("").size(LabelSize::Small)) None
.into(), }
}) ThreadStatus::Generating => div()
.children(self.render_activity_bar(&thread_clone, window, cx)) .px_5()
.into_any_element() .py_2()
.child(LoadingLabel::new("").size(LabelSize::Small))
.into(),
})
.children(self.render_activity_bar(&thread_clone, window, cx))
.into_any_element()
} else { } else {
this.child(self.render_empty_state(cx)).into_any_element() this.child(self.render_empty_state(cx)).into_any_element()
} }

View file

@ -3529,7 +3529,6 @@ impl EventEmitter<ActiveThreadEvent> for ActiveThread {}
impl Render for ActiveThread { impl Render for ActiveThread {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
v_flex() v_flex()
.id(("active-thread", cx.entity_id()))
.size_full() .size_full()
.relative() .relative()
.bg(cx.theme().colors().panel_background) .bg(cx.theme().colors().panel_background)

View file

@ -756,7 +756,7 @@ impl Render for BreakpointList {
.chain(exception_breakpoints), .chain(exception_breakpoints),
); );
v_flex() v_flex()
.id("breakpoint-list-container") .id("breakpoint-list")
.key_context("BreakpointList") .key_context("BreakpointList")
.track_focus(&self.focus_handle) .track_focus(&self.focus_handle)
.on_action(cx.listener(Self::select_next)) .on_action(cx.listener(Self::select_next))
@ -773,7 +773,6 @@ impl Render for BreakpointList {
.m_0p5() .m_0p5()
.child( .child(
v_flex() v_flex()
.id("breakpoint-list")
.size_full() .size_full()
.child(self.render_list(cx)) .child(self.render_list(cx))
.vertical_scrollbar_for(self.scroll_handle.clone(), window, cx), .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx),

View file

@ -892,7 +892,6 @@ impl Render for MemoryView {
.child(Divider::horizontal()) .child(Divider::horizontal())
.child( .child(
v_flex() v_flex()
.id("memory-view-scroll-container")
.size_full() .size_full()
.on_drag_move(cx.listener(|this, evt, _, _| { .on_drag_move(cx.listener(|this, evt, _, _| {
this.handle_memory_drag(&evt); this.handle_memory_drag(&evt);

View file

@ -270,7 +270,6 @@ impl Render for ModuleList {
self.schedule_rebuild(cx); self.schedule_rebuild(cx);
} }
div() div()
.id("module-list-container")
.track_focus(&self.focus_handle) .track_focus(&self.focus_handle)
.on_action(cx.listener(Self::select_last)) .on_action(cx.listener(Self::select_last))
.on_action(cx.listener(Self::select_first)) .on_action(cx.listener(Self::select_first))

View file

@ -680,7 +680,6 @@ impl StackFrameList {
impl Render for StackFrameList { impl Render for StackFrameList {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div() div()
.id(("stack-frame-list-container", cx.entity_id()))
.track_focus(&self.focus_handle) .track_focus(&self.focus_handle)
.size_full() .size_full()
.on_action(cx.listener(Self::select_next)) .on_action(cx.listener(Self::select_next))

View file

@ -990,7 +990,6 @@ impl DiagnosticPopover {
), ),
), ),
) )
.id("diagnostic-popover-vertical-scroll-container")
.custom_scrollbars( .custom_scrollbars(
Scrollbars::for_settings::<EditorSettings>() Scrollbars::for_settings::<EditorSettings>()
.tracked_scroll_handle(self.scroll_handle.clone()), .tracked_scroll_handle(self.scroll_handle.clone()),

View file

@ -343,7 +343,6 @@ impl SignatureHelpPopover {
let main_content = div() let main_content = div()
.occlude() .occlude()
.p_2() .p_2()
.id("signature_help_wrapper")
.child( .child(
div() div()
.id("signature_help_container") .id("signature_help_container")

View file

@ -1509,7 +1509,6 @@ impl Render for ExtensionsPage {
.child(self.render_feature_upsells(cx)) .child(self.render_feature_upsells(cx))
.child( .child(
v_flex() v_flex()
.id("extensions-page-container")
.pl_4() .pl_4()
.pr_6() .pr_6()
.size_full() .size_full()
@ -1521,17 +1520,24 @@ impl Render for ExtensionsPage {
} }
if count == 0 { if count == 0 {
return this.py_4().child(self.render_empty_state(cx)); this.py_4()
} .child(self.render_empty_state(cx))
.into_any_element()
let scroll_handle = self.list.clone(); } else {
this.child( let scroll_handle = self.list.clone();
uniform_list("entries", count, cx.processor(Self::render_extensions)) this.child(
uniform_list(
"entries",
count,
cx.processor(Self::render_extensions),
)
.flex_grow() .flex_grow()
.pb_4() .pb_4()
.track_scroll(scroll_handle.clone()), .track_scroll(scroll_handle.clone()),
) )
.vertical_scrollbar_for(scroll_handle, window, cx) .vertical_scrollbar_for(scroll_handle, window, cx)
.into_any_element()
}
}), }),
) )
} }

View file

@ -3525,7 +3525,6 @@ impl GitPanel {
.relative() .relative()
.child( .child(
h_flex() h_flex()
.id("git-panel-entries-container")
.flex_1() .flex_1()
.size_full() .size_full()
.relative() .relative()

View file

@ -4706,7 +4706,6 @@ impl OutlinePanel {
}; };
v_flex() v_flex()
.id("outline-panel-content-container")
.flex_shrink() .flex_shrink()
.size_full() .size_full()
.child(list_contents.size_full().flex_shrink()) .child(list_contents.size_full().flex_shrink())

View file

@ -1560,7 +1560,6 @@ impl RemoteServerProjects {
.section( .section(
Section::new().padded(false).child( Section::new().padded(false).child(
v_flex() v_flex()
.id("remote-server-modal")
.min_h(rems(20.)) .min_h(rems(20.))
.size_full() .size_full()
.relative() .relative()

View file

@ -889,7 +889,6 @@ impl<const COLS: usize> RenderOnce for Table<COLS> {
if let Some(state) = interaction_state.as_ref() { if let Some(state) = interaction_state.as_ref() {
content content
.id(("table-component-content", state.entity_id()))
.custom_scrollbars( .custom_scrollbars(
Scrollbars::for_settings::<EditorSettings>() Scrollbars::for_settings::<EditorSettings>()
.tracked_scroll_handle(state.read(cx).scroll_handle.clone()), .tracked_scroll_handle(state.read(cx).scroll_handle.clone()),