diff --git a/crates/ui/src/docking/dock_tests.rs b/crates/ui/src/docking/dock_tests.rs index b49c60a5..9a17ed7e 100644 --- a/crates/ui/src/docking/dock_tests.rs +++ b/crates/ui/src/docking/dock_tests.rs @@ -281,6 +281,16 @@ fn group_dropped_on_the_window_edge_without_a_dock_makes_a_new_dock() { } } +#[test] +fn tab_dragged_to_the_window_edge_without_a_dock_makes_a_dock_of_that_panel() { + let mut d = testing::DockDriver::new(docked(Side::Start, &[&[&[2, 3]]]), TestContent::default()); + let tab = d.hit(&Hit::Tab(3)).unwrap_or_else(|| panic!("{:?}", d.hits())); + let out = d.drag(tab.center(), pos2(795.0, 300.0)); + assert!(out.actions.contains(&Action::MovePanel { panel: 3, to: Target::NewDock { side: Side::End } }), "{:?}", out.actions); + assert_eq!(columns(&d.layout, Side::End), vec![vec![vec![3]]]); + assert_eq!(columns(&d.layout, Side::Start), vec![vec![vec![2]]]); +} + #[test] fn a_column_takes_groups_anywhere_in_it_and_as_tabs() { let windows = [(5, [400.0, 40.0, 150.0, 120.0]), (6, [400.0, 220.0, 150.0, 120.0]), (7, [400.0, 400.0, 150.0, 120.0])]; diff --git a/crates/ui/src/docking/render/dock.rs b/crates/ui/src/docking/render/dock.rs index 86c57be5..c2822cb6 100644 --- a/crates/ui/src/docking/render/dock.rs +++ b/crates/ui/src/docking/render/dock.rs @@ -461,8 +461,9 @@ impl Renderer<'_, P> { self.checked(action).map(|action| (action, drop.line)) } - /// The dock target a single tab drag would take: a new group or column of that panel. A new - /// dock only takes a panel that is alone in its group. + /// The dock target a single tab drag would take: a new group, column or dock of that panel. + /// A panel alone in its group takes the group's state to a new dock; one that shares its + /// group leaves the other tabs behind (P6). pub(super) fn dock_tab_proposal(&self, ctx: &Context, panel: &P, pointer: Pos2) -> Option<(Option>, Rect)> { if self.dock_covered(ctx, pointer, None) { return None; @@ -476,7 +477,8 @@ impl Renderer<'_, P> { { Action::MoveGroup { panel: panel.clone(), to } } - Target::NewDock { .. } | Target::Float { .. } => return None, + to @ Target::NewDock { .. } => Action::MovePanel { panel: panel.clone(), to }, + Target::Float { .. } => return None, }; self.checked(action).map(|action| (action, drop.line)) }