chore: reduce component overhead (#3)

Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
2026-11-09 10:09:56 +00:00
parent 6815585528
commit 1c091db699
44 changed files with 1376 additions and 1241 deletions
+8 -8
View File
@@ -112,9 +112,9 @@ fn drag(visual: &mut VisualTestContext, from: gpui::Point<Pixels>, to: gpui::Poi
fn register(dock: &Entity<DockState>, tags: &[&'static str], cx: &mut TestAppContext) {
cx.update(|cx| {
dock.update(cx, |dock, cx| {
dock.update(cx, |dock, _cx| {
for tag in tags {
dock.register_panel(descriptor(tag), cx);
dock.register_panel(descriptor(tag));
}
});
});
@@ -492,9 +492,9 @@ fn activating_a_panel_with_a_right_view_opens_the_sidebar() {
let mut cx = TestAppContext::single();
let (dock, opened, mut visual) = sidebar_window(&mut cx);
cx.update(|cx| {
dock.update(cx, |dock, cx| {
dock.register_panel(descriptor_with_right_sidebar("overview"), cx);
dock.register_panel(descriptor("inbox"), cx);
dock.update(cx, |dock, _cx| {
dock.register_panel(descriptor_with_right_sidebar("overview"));
dock.register_panel(descriptor("inbox"));
});
});
@@ -519,9 +519,9 @@ fn closing_the_displayed_tab_falls_back_to_another_right_view() {
let mut cx = TestAppContext::single();
let (dock, opened, mut visual) = sidebar_window(&mut cx);
cx.update(|cx| {
dock.update(cx, |dock, cx| {
dock.register_panel(descriptor_with_right_sidebar("overview"), cx);
dock.register_panel(descriptor_with_right_sidebar("explore"), cx);
dock.update(cx, |dock, _cx| {
dock.register_panel(descriptor_with_right_sidebar("overview"));
dock.register_panel(descriptor_with_right_sidebar("explore"));
});
});
open(&mut visual, &dock, "overview");
+22
View File
@@ -151,6 +151,28 @@ fn moves_without_a_drag_report_nothing() {
assert!(deltas.borrow().is_empty());
}
/// The button may be released outside the window, where no MouseUp is
/// delivered — the drag must end when a move reports no pressed button.
#[test]
fn releasing_outside_the_window_ends_the_drag() {
let (_cx, deltas, _resets, mut visual) = handle_window(Axis::Horizontal, false);
let start = handle_center(&mut visual);
visual.simulate_mouse_down(start, MouseButton::Left, Modifiers::default());
visual.simulate_event(MouseMoveEvent {
position: point(start.x + px(30.), start.y),
pressed_button: None,
modifiers: Modifiers::default(),
});
visual.simulate_event(MouseMoveEvent {
position: point(start.x + px(60.), start.y),
pressed_button: None,
modifiers: Modifiers::default(),
});
assert!(deltas.borrow().is_empty(), "the drag outlived its button");
}
#[test]
fn arrow_keys_move_the_seam_when_focused() {
let (_cx, deltas, _resets, mut visual) = handle_window(Axis::Horizontal, false);
+6 -14
View File
@@ -74,9 +74,7 @@ fn the_pill_bar_pads_for_traffic_lights_when_it_leads_the_window() {
let mut cx = TestAppContext::single();
let (dock, mut visual) = dock_window(false, false, &mut cx);
cx.update(|cx| {
dock.update(cx, |dock, cx| {
dock.register_panel(descriptor("overview"), cx)
});
dock.update(cx, |dock, _cx| dock.register_panel(descriptor("overview")));
});
open(&mut visual, &dock, "overview");
@@ -87,9 +85,7 @@ fn the_pill_bar_pads_for_traffic_lights_when_it_leads_the_window() {
let (dock, mut visual) = dock_window(false, true, &mut cx);
let _ = &dock;
cx.update(|cx| {
dock.update(cx, |dock, cx| {
dock.register_panel(descriptor("overview"), cx)
});
dock.update(cx, |dock, _cx| dock.register_panel(descriptor("overview")));
});
open(&mut visual, &dock, "overview");
@@ -101,11 +97,11 @@ fn the_pill_bar_pads_for_traffic_lights_when_it_leads_the_window() {
// The bare bar keeps the standard leading padding; the padded bar clears
// the traffic lights.
assert!(
bare_inset < px(TRAFFIC_LIGHT_PAD),
bare_inset < TRAFFIC_LIGHT_PAD,
"the bare bar must not reserve the traffic-light pad (bare {bare_inset:?})"
);
assert!(
padded_inset >= px(TRAFFIC_LIGHT_PAD) - px(1.),
padded_inset >= TRAFFIC_LIGHT_PAD - px(1.),
"the pad must clear the traffic lights (bare {bare_inset:?}, padded {padded_inset:?})"
);
}
@@ -115,9 +111,7 @@ fn window_controls_render_only_when_the_flag_is_set() {
let mut cx = TestAppContext::single();
let (dock, mut visual) = dock_window(false, false, &mut cx);
cx.update(|cx| {
dock.update(cx, |dock, cx| {
dock.register_panel(descriptor("overview"), cx)
});
dock.update(cx, |dock, _cx| dock.register_panel(descriptor("overview")));
});
open(&mut visual, &dock, "overview");
@@ -138,9 +132,7 @@ fn the_flag_hosts_the_platform_controls_in_the_bar() {
let mut cx = TestAppContext::single();
let (dock, mut visual) = dock_window(true, false, &mut cx);
cx.update(|cx| {
dock.update(cx, |dock, cx| {
dock.register_panel(descriptor("overview"), cx)
});
dock.update(cx, |dock, _cx| dock.register_panel(descriptor("overview")));
});
open(&mut visual, &dock, "overview");