Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
workspace: Fix tab reordering regression (#46872)
Yaroslav Yenkalab8c5f672cdf8
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex 318a790fdfa..9e24a132b08 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -2765,7 +2765,7 @@ impl Pane {.on_drop(cx.listener(move |this, dragged_tab: &DraggedTab, window, cx| {this.drag_split_direction = None;- this.handle_tab_drop(dragged_tab, this.items.len(), window, cx)+ this.handle_tab_drop(dragged_tab, ix, window, cx)}),).on_drop(@@ -6225,6 +6225,57 @@ mod tests {assert_item_labels(&pane_a, ["C*", "A", "B"], cx);}+ #[gpui::test]+ async fn test_drag_tab_to_middle_tab_with_mouse_events(cx: &mut TestAppContext) {+ use gpui::{Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent};++ init_test(cx);+ let fs = FakeFs::new(cx.executor());++ let project = Project::test(fs, None, cx).await;+ let (workspace, cx) =+ cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());++ add_labeled_item(&pane, "A", false, cx);+ add_labeled_item(&pane, "B", false, cx);+ add_labeled_item(&pane, "C", false, cx);+ add_labeled_item(&pane, "D", false, cx);+ assert_item_labels(&pane, ["A", "B", "C", "D*"], cx);+ cx.run_until_parked();++ let tab_a_bounds = cx+ .debug_bounds("TAB-0")+ .expect("Tab A (index 0) should have debug bounds");+ let tab_c_bounds = cx+ .debug_bounds("TAB-2")+ .expect("Tab C (index 2) should have debug bounds");++ cx.simulate_event(MouseDownEvent {+ position: tab_a_bounds.center(),+ button: MouseButton::Left,+ modifiers: Modifiers::default(),+ click_count: 1,+ first_mouse: false,+ });+ cx.run_until_parked();+ cx.simulate_event(MouseMoveEvent {+ position: tab_c_bounds.center(),+ pressed_button: Some(MouseButton::Left),+ modifiers: Modifiers::default(),+ });+ cx.run_until_parked();+ cx.simulate_event(MouseUpEvent {+ position: tab_c_bounds.center(),+ button: MouseButton::Left,+ modifiers: Modifiers::default(),+ click_count: 1,+ });+ cx.run_until_parked();++ assert_item_labels(&pane, ["B", "C", "A*", "D"], cx);+ }+#[gpui::test]async fn test_add_item_with_new_item(cx: &mut TestAppContext) {init_test(cx);