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| {
if self.list_state.item_count() > 0 {
this.id("acp-thread-list-view")
.child(
list(
self.list_state.clone(),
cx.processor(|this, index: usize, window, cx| {
let Some((entry, len)) =
this.thread().and_then(|thread| {
let entries = &thread.read(cx).entries();
Some((entries.get(index)?, entries.len()))
})
else {
return Empty.into_any();
};
this.render_entry(index, len, entry, window, cx)
}),
)
.with_sizing_behavior(gpui::ListSizingBehavior::Auto)
.flex_grow()
.into_any(),
this.child(
list(
self.list_state.clone(),
cx.processor(|this, index: usize, window, cx| {
let Some((entry, len)) = this.thread().and_then(|thread| {
let entries = &thread.read(cx).entries();
Some((entries.get(index)?, entries.len()))
}) else {
return Empty.into_any();
};
this.render_entry(index, len, entry, window, cx)
}),
)
.vertical_scrollbar(window, cx)
.children(match thread_clone.read(cx).status() {
ThreadStatus::Idle
| ThreadStatus::WaitingForToolConfirmation => None,
ThreadStatus::Generating => div()
.px_5()
.py_2()
.child(LoadingLabel::new("").size(LabelSize::Small))
.into(),
})
.children(self.render_activity_bar(&thread_clone, window, cx))
.into_any_element()
.with_sizing_behavior(gpui::ListSizingBehavior::Auto)
.flex_grow()
.into_any(),
)
.vertical_scrollbar(window, cx)
.children(match thread_clone.read(cx).status() {
ThreadStatus::Idle | ThreadStatus::WaitingForToolConfirmation => {
None
}
ThreadStatus::Generating => div()
.px_5()
.py_2()
.child(LoadingLabel::new("").size(LabelSize::Small))
.into(),
})
.children(self.render_activity_bar(&thread_clone, window, cx))
.into_any_element()
} else {
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 {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
v_flex()
.id(("active-thread", cx.entity_id()))
.size_full()
.relative()
.bg(cx.theme().colors().panel_background)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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