Visual Studio Code, rebuilt in Rust
Rust
feat(workbench): drag views and containers onto bar items and panes as upstream
rokarture28d96789f7a
diff --git a/native/crates/app/src/theme.rs b/native/crates/app/src/theme.rsindex 030f60a129f..8ebe068fe64 100644--- a/native/crates/app/src/theme.rs+++ b/native/crates/app/src/theme.rs@@ -680,6 +680,7 @@ fn registry_default(key: &str, kind: ThemeKind) -> ColorValue {"sideBarSectionHeader.border" => (Key("contrastBorder"), Key("contrastBorder"), Key("contrastBorder")),"editorGroup.dropBackground" => (Transparent(&Hex("#53595D"), 0.5), Transparent(&Hex("#2677CB"), 0.18), None),"sideBar.dropBackground" => (Key("editorGroup.dropBackground"), Key("editorGroup.dropBackground"), Key("editorGroup.dropBackground")),+ "panelSection.dropBackground" => (Key("editorGroup.dropBackground"), Key("editorGroup.dropBackground"), Key("editorGroup.dropBackground")),"list.inactiveSelectionBackground" => (Hex("#37373D"), Hex("#E4E6F1"), None),"modernTab.activeBackground" => (Key("list.inactiveSelectionBackground"), Key("list.inactiveSelectionBackground"), Key("list.inactiveSelectionBackground")),// oneOf(list.inactiveSelectionForeground, foreground), and the first has no default.@@ -976,7 +977,7 @@ fn hc_light_default(key: &str) -> ColorValue {"editorGroup.border" => Key("contrastBorder"),"sideBySideEditor.horizontalBorder" | "sideBySideEditor.verticalBorder" => Key("editorGroup.border"),"editorGroup.dropBackground" => Transparent(&Hex("#0F4A85"), 0.5),- "sideBar.dropBackground" => Key("editorGroup.dropBackground"),+ "sideBar.dropBackground" | "panelSection.dropBackground" => Key("editorGroup.dropBackground"),"disabledForeground" => Hex("#7F7F7F"),"icon.foreground" => Hex("#292929"),"editorGutter.foldingControlForeground" => Key("icon.foreground"),diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rsindex d5ab545638a..bad0b6d51c7 100644--- a/native/crates/app/src/workbench.rs+++ b/native/crates/app/src/workbench.rs@@ -1651,14 +1651,7 @@ impl Workbench {.child(self.action_hover(title, command, hover)).relative().children(self.container_activity_badge(command))- .when(view.is_some(), |icon| icon.on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| workbench.activity_item_clicked(active, command, event, window, cx))))- // compositeBar.ts `CompositeBarDndCallbacks.drop` on an item: the view moves into that container.- .when(command != "workbench.view.extensions", |icon| {- icon.on_drop(cx.listener(move |workbench, dragged: &view_panes::DraggedPane, _, cx| {- cx.stop_propagation();- workbench.drop_view_on_container(dragged.id, command, cx);- }))- });+ .when(view.is_some(), |icon| icon.on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| workbench.activity_item_clicked(active, command, event, window, cx))));(command, item)}).collect();items.extend(self.testing_activity_item(hover, window, cx).map(|item| ("workbench.view.testing", item)));@@ -1697,14 +1690,7 @@ impl Workbench {.children(items.into_iter().map(|(_, item)| item)),cx,))- // compositeBar.ts `CompositeBarDndCallbacks.drop`: a view dropped on the bar moves to a new side bar entry.- .on_drop(cx.listener(|workbench, dragged: &view_panes::DraggedPane, _, cx| workbench.drop_view_on_location(dragged.id, layout::Part::SideBar, cx)))- // compositeBar.ts `CompositeBarDndCallbacks.onDrop`: a composite dropped past the items goes after the last one.- .on_drop(cx.listener(|workbench, dragged: &panel::DraggedComposite, window, cx| {- let unpinned = workbench.unpinned_containers(layout::Part::SideBar);- let last = workbench.activity_bar_containers().into_iter().map(|(id, _)| id).rfind(|id| !unpinned.iter().any(|other| other == id));- workbench.drop_composite(dragged.id, layout::Part::SideBar, last.map(|id| (id, false)), window, cx);- }))+ .map(|bar| self.with_bar_end_drop(bar, layout::Part::SideBar, cx)).on_mouse_down(MouseButton::Right, cx.listener(|workbench, event: &MouseDownEvent, window, cx| workbench.show_activity_bar_context_menu(event.position, window, cx))).child(self.action_bar("global-activity", true, div().child(self.action_bar_item("global-activity", "manage",self.icon(self.manage_activity_icon(), 36., 24., self.activity_item_foreground("global-activity", "manage", window, cx))diff --git a/native/crates/app/src/workbench/activity_bar_menu.rs b/native/crates/app/src/workbench/activity_bar_menu.rsindex 8a0d79eb230..640c0f840e8 100644--- a/native/crates/app/src/workbench/activity_bar_menu.rs+++ b/native/crates/app/src/workbench/activity_bar_menu.rs@@ -4,7 +4,7 @@use std::collections::HashMap;-use gpui::{AppContext, Bounds, Context, Div, InteractiveElement, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, SharedString, Stateful, StatefulInteractiveElement, Window, prelude::FluentBuilder};+use gpui::{App, AppContext, Bounds, Context, Div, InteractiveElement, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, SharedString, Stateful, StatefulInteractiveElement, Window, prelude::FluentBuilder};use serde_json::{Value, json};use super::Workbench;@@ -151,10 +151,7 @@ impl Workbench {if self.container_location(container) != part {self.move_view_container(container, part, window, cx);let Some((target, before)) = target else { return };- let mut ids: Vec<_> = self.bar_items(part).into_iter().map(|(item, _)| item).filter(|item| *item != id).collect();- let index = ids.iter().position(|item| *item == target).map_or(ids.len(), |index| index + usize::from(!before));- ids.insert(index, id);- self.save_bar_items(part, &ids, &self.unpinned_containers(part));+ self.place_bar_item(part, id, target, before);return cx.notify();}let Some((target, before)) = target else { return };@@ -179,6 +176,14 @@ impl Workbench {self.focus_pane_composite(part, window, cx);}+ /// `getTargetIndex`: `id` goes into `part`'s stored bar order before or after `target`.+ pub(super) fn place_bar_item(&self, part: Part, id: &'static str, target: &'static str, before: bool) {+ let mut ids: Vec<_> = self.bar_items(part).into_iter().map(|(item, _)| item).filter(|item| *item != id).collect();+ let index = ids.iter().position(|item| *item == target).map_or(ids.len(), |index| index + usize::from(!before));+ ids.insert(index, id);+ self.save_bar_items(part, &ids, &self.unpinned_containers(part));+ }+/// viewDescriptorService.ts `getViewContainerBadgeEnablementState`.pub(super) fn badges_enabled(&self, container: &str) -> bool {self.view_customizations()[BADGE_STATES][container] != false@@ -374,12 +379,39 @@ impl Workbench {pub(super) fn with_composite_drop(&self, item: Stateful<Div>, bar: &'static str, id: &'static str, part: Part, cx: &mut Context<Self>) -> Stateful<Div> {item.on_drop(cx.listener(move |workbench, dragged: &DraggedComposite, window, cx| {cx.stop_propagation();- let bounds = workbench.drawn_action_bar_item_bounds(bar, id, cx);- let pointer = window.mouse_position();- // The activity bar is the one vertical composite bar.- let before = if bar == "activity" { pointer.y <= bounds.center().y } else { pointer.x <= bounds.center().x };+ let before = workbench.drops_before(bar, id, window, cx);workbench.drop_composite(dragged.id, part, Some((id, before)), window, cx);}))+ .on_drop(cx.listener(move |workbench, dragged: &super::view_panes::DraggedPane, window, cx| {+ cx.stop_propagation();+ let before = workbench.drops_before(bar, id, window, cx);+ workbench.drop_view_on_location(dragged.id, part, Some((id, before)), cx);+ }))+ }++ /// compositeBar.ts `CompositeBarDndCallbacks.onDrop`: a composite or a view dropped on `part`'s bar past its items+ /// goes after the last one.+ pub(super) fn with_bar_end_drop<E: InteractiveElement>(&self, bar: E, part: Part, cx: &mut Context<Self>) -> E {+ let last = move |workbench: &Self| {+ let unpinned = workbench.unpinned_containers(part);+ workbench.bar_items(part).into_iter().map(|(id, _)| id).rfind(|id| !unpinned.iter().any(|other| other == id)).map(|id| (id, false))+ };+ bar.on_drop(cx.listener(move |workbench, dragged: &DraggedComposite, window, cx| {+ cx.stop_propagation();+ workbench.panel.drop_target = None;+ workbench.drop_composite(dragged.id, part, last(workbench), window, cx);+ }))+ .on_drop(cx.listener(move |workbench, dragged: &super::view_panes::DraggedPane, _, cx| {+ cx.stop_propagation();+ workbench.drop_view_on_location(dragged.id, part, last(workbench), cx);+ }))+ }++ /// Whether the pointer is in the first half of `bar`'s item `id`; the activity bar is the one vertical bar.+ fn drops_before(&self, bar: &'static str, id: &'static str, window: &Window, cx: &App) -> bool {+ let bounds = self.drawn_action_bar_item_bounds(bar, id, cx);+ let pointer = window.mouse_position();+ if bar == "activity" { pointer.y <= bounds.center().y } else { pointer.x <= bounds.center().x }}/// paneCompositeBar.ts: a container at its default location with one view whose default container is anotherdiff --git a/native/crates/app/src/workbench/panel.rs b/native/crates/app/src/workbench/panel.rsindex 1589c4c0c03..f47b66269fc 100644--- a/native/crates/app/src/workbench/panel.rs+++ b/native/crates/app/src/workbench/panel.rs@@ -84,7 +84,7 @@ pub(super) struct Panel {panel_bar: CompositeBar,auxiliary_bar: CompositeBar,/// The part a dragged view container is over (`CompositeDragAndDropObserver` `onDragEnter`).- drop_target: Option<Part>,+ pub(super) drop_target: Option<Part>,}/// A part title's action bars (actionbar.ts), one tab stop each: the composite bar's tabs and the global actions.@@ -472,27 +472,22 @@ impl Workbench {let view_actions = merged_view.or(active).zip(view_actions);self.pane_composite_card(part, background).on_drag_move(cx.listener(move |workbench, event: &DragMoveEvent<DraggedComposite>, _, cx| {- let over = event.bounds.contains(&event.event.position);- let target = if over { Some(part) } else { workbench.panel.drop_target.filter(|target| *target != part) };- if workbench.panel.drop_target != target {- workbench.panel.drop_target = target;- cx.notify();- }+ workbench.track_part_drop_target(part, event.bounds.contains(&event.event.position), cx);+ }))+ .on_drag_move(cx.listener(move |workbench, event: &DragMoveEvent<super::view_panes::DraggedPane>, _, cx| {+ let over = event.bounds.contains(&event.event.position) && workbench.can_move_view(event.drag(cx).id);+ workbench.track_part_drop_target(part, over, cx);}))+ // paneCompositePart.ts `createEmptyPaneMessage` registers the whole part as a composite bar drop target..on_drop(cx.listener(move |workbench, dragged: &DraggedComposite, window, cx| {workbench.panel.drop_target = None;workbench.drop_composite(dragged.id, part, None, window, cx);}))- .child(self.pane_composite_title(part, tabs, view_actions, actions, drop_feedback, cx).on_drop(cx.listener(move |workbench, dragged: &super::view_panes::DraggedPane, _, cx| {- workbench.drop_view_on_location(dragged.id, part, cx);- }))- // compositeBar.ts `CompositeBarDndCallbacks.onDrop`: a composite dropped past the tabs goes after the last one.- .on_drop(cx.listener(move |workbench, dragged: &DraggedComposite, window, cx| {- cx.stop_propagation();+ .on_drop(cx.listener(move |workbench, dragged: &super::view_panes::DraggedPane, _, cx| {workbench.panel.drop_target = None;- let last = workbench.part_tabs(part).last().map(|tab| (tab.id, false));- workbench.drop_composite(dragged.id, part, last, window, cx);- })))+ workbench.drop_view_on_location(dragged.id, part, None, cx);+ }))+ .child(self.with_bar_end_drop(self.pane_composite_title(part, tabs, view_actions, actions, drop_feedback, cx), part, cx)).child(div().relative().flex_1().min_h_0().flex().flex_col().child(size_tracker(content_bounds)).child(content).children(progress_bars))}@@ -513,16 +508,17 @@ impl Workbench {let after_explorer = usize::from(views.first() == Some(&super::testing_view::TESTING_VIEW));views.insert(after_explorer, super::testing_coverage_view::TEST_COVERAGE_VIEW);}- if let [view] = views[..] {- let pane = self.movable_view_pane(view, window, cx);- return (pane.body, pane.actions);- }// viewPaneContainer.ts `orientation`: a top or bottom panel lays its panes side by side.let part = self.container_location(container);let horizontal = part == Part::Panel && self.arrangement().panel.is_horizontal();+ let panes_of = super::view_locations::pane_container(container);+ if let [view] = views[..] {+ let pane = self.movable_view_pane(view, window, cx);+ let body = div().id(view).relative().flex_1().min_h_0().flex().flex_col().child(pane.body);+ return (self.with_pane_drop(body, panes_of, view, horizontal, cx).into_any_element(), pane.actions);+ }let content = self.composite_bar(part).content_bounds.get().size;let size = f32::from(if horizontal { content.width } else { content.height });- let panes_of = super::view_locations::pane_container(container);self.layout_panes(panes_of, size, views.iter().map(|&view| (view, self.view_collapsed_by_default(view))).collect(), horizontal, cx);let panes = views.into_iter().map(|view| self.movable_view_pane(view, window, cx)).collect();let ordered = self.ordered_panes(&self.panes(panes_of).view.as_ref().expect("laid out above").ids(), panes, window, cx);@@ -530,6 +526,14 @@ impl Workbench {(self.pane_view_element(panes_of, ordered, window, cx).into_any_element(), more)}+ fn track_part_drop_target(&mut self, part: Part, over: bool, cx: &mut Context<Self>) {+ let target = if over { Some(part) } else { self.panel.drop_target.filter(|target| *target != part) };+ if self.panel.drop_target != target {+ self.panel.drop_target = target;+ cx.notify();+ }+ }+fn composite_bar(&self, part: Part) -> &CompositeBar {match part {Part::AuxiliaryBar => &self.panel.auxiliary_bar,@@ -648,11 +652,6 @@ impl Workbench {.children(badge).child(self.panel_tab_hover(view, window)).on_drag(dragged, |dragged, _, _, cx| cx.new(|_| dragged.clone()))- // compositeBar.ts: a view dropped on a tab moves into that container.- .on_drop(cx.listener(move |workbench, dragged: &super::view_panes::DraggedPane, _, cx| {- cx.stop_propagation();- workbench.drop_view_on_container(dragged.id, id, cx);- })).on_click(cx.listener(move |workbench, _, window, cx| match workbench.panel.views.iter().find(|view| view.id == id) {Some(view) => (view.open)(workbench, window, cx),None => workbench.show_view_container(id, cx),diff --git a/native/crates/app/src/workbench/side_bar.rs b/native/crates/app/src/workbench/side_bar.rsindex 98cde83b118..a34b7047f0e 100644--- a/native/crates/app/src/workbench/side_bar.rs+++ b/native/crates/app/src/workbench/side_bar.rs@@ -89,7 +89,8 @@ impl Workbench {let line = div().absolute().left_0().right_0().h(px(1.)).bg(self.connected_pane_tab_border());let line = if footer { line.top_0() } else { line.bottom_0() };let strip = div().relative().h(px(32.)).flex_none().flex().bg(self.tab_strip_background()).child(line);- self.action_bar(COMPACT_ACTIVITY_BAR, false, strip, cx).children(tabs)+ let bar = self.action_bar(COMPACT_ACTIVITY_BAR, false, strip, cx).children(tabs);+ self.with_bar_end_drop(bar, super::layout::Part::SideBar, cx)}/// `compact_activity_icon`'s glyph as a drag image.diff --git a/native/crates/app/src/workbench/view_locations.rs b/native/crates/app/src/workbench/view_locations.rsindex 43b1461ee2f..300c9bfc1ab 100644--- a/native/crates/app/src/workbench/view_locations.rs+++ b/native/crates/app/src/workbench/view_locations.rs@@ -305,22 +305,16 @@ impl Workbench {id}- /// A view header dropped on a composite bar: the view moves to a new entry there and opens.- pub(super) fn drop_view_on_location(&mut self, view: &'static str, part: Part, cx: &mut Context<Self>) {+ /// compositeBar.ts `CompositeDragAndDrop.drop` of a `view` on `part`'s bar: the view moves to a new container+ /// there, which takes the drop position next to `target` (`moveComposite`) and opens.+ pub(super) fn drop_view_on_location(&mut self, view: &'static str, part: Part, target: Option<(&'static str, bool)>, cx: &mut Context<Self>) {if !self.can_move_view(view) {return;}let container = self.move_view_to_location(view, part, cx);- self.open_view_container_of(container, view, cx);- }-- /// A view dropped on a container's activity bar item or panel tab moves into it and opens there.- pub(super) fn drop_view_on_container(&mut self, view: &'static str, container: &'static str, cx: &mut Context<Self>) {- let Some(movable) = self.movable_view(view) else { return };- if self.view_container(&movable) == container {- return;+ if let Some((target, before)) = target {+ self.place_bar_item(part, container, target, before);}- self.move_view_to_container(view, container, cx);self.open_view_container_of(container, view, cx);}diff --git a/native/crates/app/src/workbench/view_locations/tests.rs b/native/crates/app/src/workbench/view_locations/tests.rsindex 247549396ba..25745ff441a 100644--- a/native/crates/app/src/workbench/view_locations/tests.rs+++ b/native/crates/app/src/workbench/view_locations/tests.rs@@ -155,7 +155,7 @@ fn a_view_alone_in_a_new_side_bar_entry_is_not_offered_another_one(cx: &mut Test}#[gpui::test]-fn outline_header_dragged_onto_the_source_control_item_moves_it_there(cx: &mut TestAppContext) {+fn outline_header_dragged_onto_the_source_control_item_gets_a_new_container_before_it(cx: &mut TestAppContext) {let profile = Arc::new(Mutex::new(Storage::in_memory()));let (workbench, cx) = open(profile.clone(), cx);let header = cx.debug_bounds("pane-header-outline").unwrap().center();@@ -165,10 +165,13 @@ fn outline_header_dragged_onto_the_source_control_item_moves_it_there(cx: &mut Tcx.simulate_mouse_move(item, gpui::MouseButton::Left, gpui::Modifiers::none());cx.simulate_mouse_up(item, gpui::MouseButton::Left, gpui::Modifiers::none());cx.run_until_parked();- assert_eq!(stored(&profile)["viewLocations"], json!({ OUTLINE_VIEW: SCM_CONTAINER }));- let scm = workbench.read_with(cx, |workbench, _| (workbench.side_bar_view, workbench.panes(PaneContainer::Scm).view.as_ref().unwrap().ids().to_vec()));- assert_eq!(scm.0, SideBarView::Scm);- assert_eq!(scm.1.last(), Some(&OUTLINE_VIEW));+ // compositeBar.ts `CompositeDragAndDrop.drop` of a `view` on an item: `moveViewToLocation`, then `moveComposite`.+ let container = workbench.read_with(cx, |workbench, _| workbench.view_container(&workbench.movable_view(OUTLINE_VIEW).unwrap()));+ assert!(is_generated_container(container), "{container}");+ let order: Vec<_> = workbench.read_with(cx, |workbench, _| workbench.activity_bar_containers().into_iter().map(|(id, _)| id).collect());+ let scm = order.iter().position(|id| *id == SCM_CONTAINER).unwrap();+ assert_eq!(order[scm - 1], container, "{order:?}");+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.side_bar_view), SideBarView::Generated(container));}#[gpui::test]@@ -564,3 +567,44 @@ fn the_extensions_and_testing_containers_move_to_the_panel_and_the_secondary_sidassert_eq!(stored(&profile)["viewContainerLocations"], json!({}));assert_eq!(workbench.read_with(cx, |workbench, _| workbench.side_bar_view), SideBarView::Testing);}++#[gpui::test]+fn a_view_dropped_on_a_bar_item_gets_a_new_container_at_the_drop_position(cx: &mut TestAppContext) {+ let (workbench, cx) = open(Arc::new(Mutex::new(Storage::in_memory())), cx);+ workbench.update(cx, |workbench, cx| workbench.drop_view_on_location(OUTLINE_VIEW, Part::SideBar, Some((SEARCH_CONTAINER, false)), cx));+ cx.run_until_parked();+ workbench.read_with(cx, |workbench, _| {+ let container = workbench.view_container(&workbench.movable_view(OUTLINE_VIEW).unwrap());+ assert!(is_generated_container(container), "{container}");+ let order: Vec<_> = workbench.activity_bar_containers().into_iter().map(|(id, _)| id).collect();+ let search = order.iter().position(|id| *id == SEARCH_CONTAINER).unwrap();+ assert_eq!(order.get(search + 1), Some(&container), "{order:?}");+ assert_eq!(workbench.side_bar_view, SideBarView::Generated(container));+ });+}++#[gpui::test]+fn a_container_dropped_on_a_pane_merges_its_views_beside_it(cx: &mut TestAppContext) {+ let profile = Arc::new(Mutex::new(Storage::in_memory()));+ let (workbench, cx) = open(profile.clone(), cx);+ workbench.read_with(cx, |workbench, _| {+ assert!(!workbench.can_merge_container(EXPLORER_CONTAINER, EXPLORER_CONTAINER));+ assert!(!workbench.can_merge_container(MARKERS_CONTAINER_ID, crate::workbench::extensions_view::VIEWLET_ID));+ assert!(!workbench.can_merge_container(crate::workbench::extensions_view::VIEWLET_ID, EXPLORER_CONTAINER));+ });+ let target = crate::workbench::view_panes::EMPTY_VIEW;+ workbench.update(cx, |workbench, cx| workbench.merge_container_into(MARKERS_CONTAINER_ID, PaneContainer::Explorer, Some((target, true)), cx));+ cx.run_until_parked();+ assert_eq!(explorer_panes(&workbench, cx), [target, MARKERS_VIEW_ID, OUTLINE_VIEW, TIMELINE_VIEW]);+ assert_eq!(stored(&profile)["viewLocations"], json!({ MARKERS_VIEW_ID: EXPLORER_CONTAINER }));+ assert!(workbench.read_with(cx, |workbench, _| !workbench.part_tabs(Part::Panel).iter().any(|tab| tab.id == MARKERS_CONTAINER_ID)));+}++#[gpui::test]+fn a_header_dropped_on_a_panel_view_shown_alone_moves_into_its_container(cx: &mut TestAppContext) {+ let (workbench, cx) = open(Arc::new(Mutex::new(Storage::in_memory())), cx);+ let output = crate::workbench::output_view::OUTPUT_VIEW_ID;+ workbench.update(cx, |workbench, cx| workbench.drop_pane_from_container(OUTLINE_VIEW, pane_container(output), output, false, cx));+ cx.run_until_parked();+ assert!(workbench.read_with(cx, |workbench, _| workbench.view_container(&workbench.movable_view(OUTLINE_VIEW).unwrap()) == output));+}diff --git a/native/crates/app/src/workbench/view_panes.rs b/native/crates/app/src/workbench/view_panes.rsindex 28f8621b11e..c7fc151e5b9 100644--- a/native/crates/app/src/workbench/view_panes.rs+++ b/native/crates/app/src/workbench/view_panes.rs@@ -9,7 +9,7 @@ use std::rc::Rc;use gpui::{AnyElement, AppContext, Bounds, Context, Div, DragMoveEvent, FocusHandle, FontWeight, InteractiveElement, IntoElement, KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Render, Rgba,- StatefulInteractiveElement, Styled, Task, Window, canvas, div, prelude::FluentBuilder, px, svg,+ Stateful, StatefulInteractiveElement, Styled, Task, Window, canvas, div, prelude::FluentBuilder, px, svg,};use serde_json::{Value, json};@@ -546,7 +546,8 @@ impl Workbench {/// before it or after it by the half it was dropped on.pub(super) fn drop_pane_from_container(&mut self, dragged: &'static str, container: PaneContainer, target: &'static str, below: bool, cx: &mut Context<Self>) {self.panes_mut(container).drop = None;- let mut ids = self.panes(container).view.as_ref().expect("panes are laid out before they draw").ids().to_vec();+ // A panel container with one view draws it merged, without a pane view.+ let mut ids = self.panes(container).view.as_ref().map_or(vec![target], |view| view.ids().to_vec());let index = ids.iter().position(|&id| id == target).expect("the target is a pane") + usize::from(below);ids.insert(index, dragged);let key = format!("{}.hidden", container_storage_id(container.key()));@@ -556,6 +557,27 @@ impl Workbench {self.move_view_to_container(dragged, container.container_id(), cx);}+ /// viewPaneContainer.ts `onDrop` of a `composite` on a pane: the container's views move into `container`, its+ /// first one beside `target`.+ pub(super) fn merge_container_into(&mut self, dragged: &'static str, container: PaneContainer, target: Option<(&'static str, bool)>, cx: &mut Context<Self>) {+ if !self.can_merge_container(dragged, container.container_id()) {+ return;+ }+ let views = self.views_in(dragged);+ for (index, view) in views.iter().enumerate() {+ match target {+ Some((target, below)) if index == 0 => self.drop_pane_from_container(view.id, container, target, below, cx),+ _ => self.move_view_to_container(view.id, container.container_id(), cx),+ }+ }+ }++ /// Whether `dragged`'s views can all move into `container`; the port cannot move the Testing views, and the+ /// Extensions container takes none (`rejectAddedViews`).+ pub(super) fn can_merge_container(&self, dragged: &str, container: &str) -> bool {+ dragged != container && container != EXTENSIONS_CONTAINER && dragged != TESTING_CONTAINER && !self.views_in(dragged).is_empty()+ }+/// A `ViewPaneContainer` in the side bar, laid out by `layout_view_panes`: the composite title, then the panes/// in their stored order; `panes` are the container's own views, a contributed one is a tree view. A single view/// merges into the container: no header, its title in the composite title (`getTitle`) beside its actions. The@@ -581,8 +603,8 @@ impl Workbench {// paneviewlet.css: a merged view's progress bar sits 2px above its pane, over the title's bottom.// explorerView.ts `PRESERVE_MERGED_WORKSPACE_NAME_CASE_CLASS`: the folder's name keeps its case.let title = self.side_bar_title_shared(self.view_header_text(&title, id == FILE_VIEW), false).children(self.scoped_progress_bar(id).map(|bar| bar.bottom_0())).when(id == FILE_VIEW, |title| title.child(self.explorer_title_actions(window, cx))).children(pane.actions.map(|actions| self.action_bar(id, false, div().flex().flex_none().child(actions), cx))).children(more);- let body = div().flex_1().min_h_0().flex().flex_col().child(pane.body);- return frame.child(title).child(body);+ let body = div().id(id).relative().flex_1().min_h_0().flex().flex_col().child(pane.body);+ return frame.child(title).child(self.with_pane_drop(body, container, id, false, cx));}let bar = container.key();let title = self.side_bar_title_text(crate::nls::localize_in(container.container_id(), title).into_owned()).child(self.container_title_more(container, bar, cx));@@ -645,14 +667,11 @@ impl Workbench {/// its header turned into a column (paneview.css `.pane.horizontal:not(.expanded)`).#[allow(clippy::too_many_arguments)]fn pane(&self, container: PaneContainer, id: &'static str, size: f32, header: Div, body: Option<AnyElement>, horizontal: bool, cx: &mut Context<Self>) -> AnyElement {- let drop = self.panes(container).drop.filter(|(target, _)| *target == id && cx.has_active_drag()).map(|(_, below)| below);- let overlay = self.color("sideBar.dropBackground");let tracked = self.panes(container).bounds.clone();- let outline = self.theme.color("contrastActiveBorder");let first = self.panes(container).view.as_ref().is_some_and(|view| view.ids().first() == Some(&id));let left_border = self.theme.color("panelSection.border").filter(|_| horizontal && !first);let collapsed_column = horizontal && body.is_none();- div()+ let pane = div().id(id).relative().when(horizontal, |pane| pane.w(px(size)).h_full())@@ -666,40 +685,70 @@ impl Workbench {.child(header).when_some(body, |pane, body| pane.child(div().flex_1().min_h_0().flex().flex_col().child(body))).child(canvas(move |bounds, _, _| _ = tracked.borrow_mut().insert(id, bounds), |_, _, _, _| ()).absolute().inset_0())- .on_hover(cx.listener(|_, _: &bool, _, cx| cx.notify()))- .on_drag_move(cx.listener(move |workbench, event: &DragMoveEvent<DraggedPane>, _, cx| {- if !event.bounds.contains(&event.event.position) {- return;- }- let dragged = event.drag(cx);- let below = match horizontal {- true => event.event.position.x >= event.bounds.center().x,- false => event.event.position.y >= event.bounds.center().y,- };- let accepts = dragged.container == container || workbench.can_move_view(dragged.id);- let drop = (accepts && dragged.id != id).then_some((id, below));- let panes = workbench.panes_mut(container);- if panes.drop != drop {- panes.drop = drop;- cx.notify();- }- }))- .on_drop(cx.listener(move |workbench, dragged: &DraggedPane, _, cx| {- let below = workbench.panes(container).drop.filter(|(target, _)| *target == id).map(|(_, below)| below);- match below {- Some(below) if dragged.container != container => workbench.drop_pane_from_container(dragged.id, container, id, below, cx),- Some(below) => workbench.drop_pane(container, dragged.id, id, below, cx),- None => workbench.panes_mut(container).drop = None,- }- }))- .when_some(drop, |pane, below| {- let half = match horizontal {- true => div().absolute().top_0().bottom_0().w(gpui::relative(0.5)).bg(overlay).when(below, |half| half.right_0()).when(!below, |half| half.left_0()),- false => div().absolute().left_0().right_0().h(gpui::relative(0.5)).bg(overlay).when(below, |half| half.bottom_0()).when(!below, |half| half.top_0()),- };- pane.child(half.when_some(outline, |half, color| half.border_2().border_dashed().border_color(color)))- })- .into_any_element()+ .on_hover(cx.listener(|_, _: &bool, _, cx| cx.notify()));+ self.with_pane_drop(pane, container, id, horizontal, cx).into_any_element()+ }++ /// viewPaneContainer.ts `registerTarget` on a pane's `dropTargetElement` with its `ViewPaneDropOverlay`: a view+ /// header or a container's composite dropped on the first or second half of pane `id` moves there.+ pub(super) fn with_pane_drop(&self, pane: Stateful<Div>, container: PaneContainer, id: &'static str, horizontal: bool, cx: &mut Context<Self>) -> Stateful<Div> {+ let drop = self.panes_laid_out(container).then(|| self.panes(container).drop).flatten();+ let drop = drop.filter(|(target, _)| *target == id && cx.has_active_drag()).map(|(_, below)| below);+ let panel = self.container_location(container.container_id()) == super::layout::Part::Panel;+ let overlay = self.color(if panel { "panelSection.dropBackground" } else { "sideBar.dropBackground" });+ let outline = self.theme.color("contrastActiveBorder");+ let below_pointer = move |event_bounds: Bounds<Pixels>, position: gpui::Point<Pixels>| match horizontal {+ true => position.x >= event_bounds.center().x,+ false => position.y >= event_bounds.center().y,+ };+ pane.on_drag_move(cx.listener(move |workbench, event: &DragMoveEvent<DraggedPane>, _, cx| {+ if !event.bounds.contains(&event.event.position) {+ return;+ }+ let dragged = event.drag(cx);+ let accepts = dragged.container == container || workbench.can_move_view(dragged.id);+ workbench.set_pane_drop(container, (accepts && dragged.id != id).then_some((id, below_pointer(event.bounds, event.event.position))), cx);+ }))+ .on_drag_move(cx.listener(move |workbench, event: &DragMoveEvent<super::panel::DraggedComposite>, _, cx| {+ if !event.bounds.contains(&event.event.position) {+ return;+ }+ let accepts = workbench.can_merge_container(event.drag(cx).id, container.container_id());+ workbench.set_pane_drop(container, accepts.then_some((id, below_pointer(event.bounds, event.event.position))), cx);+ }))+ .on_drop(cx.listener(move |workbench, dragged: &DraggedPane, _, cx| {+ cx.stop_propagation();+ let below = workbench.panes_mut(container).drop.filter(|(target, _)| *target == id).map(|(_, below)| below);+ match below {+ Some(below) if dragged.container != container => workbench.drop_pane_from_container(dragged.id, container, id, below, cx),+ Some(below) => workbench.drop_pane(container, dragged.id, id, below, cx),+ None => workbench.panes_mut(container).drop = None,+ }+ }))+ .on_drop(cx.listener(move |workbench, dragged: &super::panel::DraggedComposite, _, cx| {+ cx.stop_propagation();+ workbench.panel.drop_target = None;+ let below = workbench.panes_mut(container).drop.filter(|(target, _)| *target == id).map(|(_, below)| below);+ workbench.panes_mut(container).drop = None;+ if let Some(below) = below {+ workbench.merge_container_into(dragged.id, container, Some((id, below)), cx);+ }+ }))+ .when_some(drop, |pane, below| {+ let half = match horizontal {+ true => div().absolute().top_0().bottom_0().w(gpui::relative(0.5)).bg(overlay).when(below, |half| half.right_0()).when(!below, |half| half.left_0()),+ false => div().absolute().left_0().right_0().h(gpui::relative(0.5)).bg(overlay).when(below, |half| half.bottom_0()).when(!below, |half| half.top_0()),+ };+ pane.child(half.when_some(outline, |half, color| half.border_2().border_dashed().border_color(color)))+ })+ }++ fn set_pane_drop(&mut self, container: PaneContainer, drop: Option<(&'static str, bool)>, cx: &mut Context<Self>) {+ let panes = self.panes_mut(container);+ if panes.drop != drop {+ panes.drop = drop;+ cx.notify();+ }}pub(super) fn pane_header_focused(&self, id: &'static str, window: &Window) -> bool {diff --git a/port/fixtures/ui-steps/dnd-1.json b/port/fixtures/ui-steps/dnd-1.jsonnew file mode 100644index 00000000000..75a257708d3--- /dev/null+++ b/port/fixtures/ui-steps/dnd-1.json@@ -0,0 +1,5 @@+[{"wait": 5000}, {"hotkey": ["cmd", "shift", "m"]}, {"wait": 1500}, {"hotkey": ["cmd", "alt", "b"]}, {"wait": 1500},+ {"dragShot": [58, 52, 375, 505], "shot": "1a-search-over-output"}, {"wait": 1500}, {"shot": "1b-search-dropped"},+ {"dragShot": [305, 505, 850, 52], "shot": "1c-problems-over-aux-title"}, {"wait": 1500}, {"shot": "1d-problems-dropped"},+ {"dragShot": [130, 52, 12, 52], "shot": "1e-debug-over-explorer"}, {"wait": 1500}, {"shot": "1f-debug-reordered"},+ {"hotkey": ["cmd", "q"]}, {"wait": 3000}, {"restart": true}, {"wait": 6000}, {"shot": "1g-restarted"}]diff --git a/port/fixtures/ui-steps/dnd-2.json b/port/fixtures/ui-steps/dnd-2.jsonnew file mode 100644index 00000000000..a4f231d2dbe--- /dev/null+++ b/port/fixtures/ui-steps/dnd-2.json@@ -0,0 +1,4 @@+[{"wait": 5000}, {"hotkey": ["cmd", "shift", "m"]}, {"wait": 1500}, {"hotkey": ["cmd", "alt", "b"]}, {"wait": 1500},+ {"dragShot": [100, 688, 62, 52], "shot": "2a-outline-over-search"}, {"wait": 2500}, {"shot": "2b-outline-dropped"},+ {"dragShot": [100, 716, 380, 505], "shot": "2c-timeline-over-output"}, {"wait": 2500}, {"shot": "2d-timeline-dropped"},+ {"hotkey": ["cmd", "q"]}, {"wait": 3000}, {"restart": true}, {"wait": 6000}, {"shot": "2e-restarted"}]diff --git a/port/fixtures/ui-steps/dnd-3.json b/port/fixtures/ui-steps/dnd-3.jsonnew file mode 100644index 00000000000..3113f158833--- /dev/null+++ b/port/fixtures/ui-steps/dnd-3.json@@ -0,0 +1,4 @@+[{"wait": 5000}, {"hotkey": ["cmd", "shift", "m"]}, {"wait": 1500}, {"hotkey": ["cmd", "alt", "b"]}, {"wait": 1500},+ {"dragShot": [305, 505, 250, 400], "shot": "3a-problems-over-explorer-body"}, {"wait": 1500}, {"shot": "3b-problems-dropped"},+ {"dragShot": [305, 505, 900, 400], "shot": "3c-tab-over-aux-body"}, {"wait": 1500}, {"shot": "3d-dropped"},+ {"dragShot": [400, 505, 700, 620], "shot": "3e-tab-over-panel-body"}, {"wait": 1500}, {"shot": "3f-dropped"}]diff --git a/port/fixtures/ui-steps/dnd-4.json b/port/fixtures/ui-steps/dnd-4.jsonnew file mode 100644index 00000000000..8e5122753a5--- /dev/null+++ b/port/fixtures/ui-steps/dnd-4.json@@ -0,0 +1,5 @@+[{"wait": 5000}, {"hotkey": ["cmd", "shift", "m"]}, {"wait": 1500}, {"hotkey": ["cmd", "alt", "b"]}, {"wait": 1500},+ {"dragShot": [387, 505, 900, 400], "shot": "4a-output-over-aux-body"}, {"wait": 1500}, {"shot": "4b-output-in-aux"},+ {"dragShot": [94, 52, 900, 400], "shot": "4c-scm-over-aux-view"}, {"wait": 1500}, {"shot": "4d-dropped"},+ {"dragShot": [100, 716, 900, 600], "shot": "4e-timeline-over-aux-view"}, {"wait": 1500}, {"shot": "4f-dropped"},+ {"dragShot": [100, 688, 400, 620], "shot": "4g-outline-over-panel-body"}, {"wait": 1500}, {"shot": "4h-dropped"}]diff --git a/port/ledger.md b/port/ledger.mdindex d2447ca2ab4..3874c13adec 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -516,7 +516,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/services/notification | workbench service | M11 | verified | | `notify`, `prompt` and the Do Not Disturb filters (global and per source, stored in application storage) on Workbench (notifications_view.rs); cargo test -p app notifications_view; verified: ui-pair messages.json vs the reference (port/results/windows.md, milestone 11 verification) || workbench/services/outline | workbench service | M13 | verified | | the document symbols outline of the active editor (workbench/outline_pane.rs): breadcrumb symbols from `getItemEnclosingPosition` with `breadcrumbs.symbolPath` and `breadcrumbs.show*`, the Outline view's tree, drawing only the rows in view as listView.ts does (cargo test -p app the_outline_draws_only_the_rows_in_view); cargo test -p app outline_pane; ui-pair Outline title actions with a.ts symbols (port/results/language-features.md Outline title actions) || workbench/services/output | workbench service | M15 | verified | | a logger's `group` is set only by the shared process (workbench/services/sharedProcess) and the hidden telemetry loggers (workbench/contrib/telemetry), `when` by no caller. output.rs: channels read from their files from a start offset, Replace/Clear move it, log channels from visible loggers, `OutputViewFilters` and `parseLogEntryAt` (output/filter.rs), the active channel and its log level: cargo test -p app output (14 tests) |-| workbench/services/panecomposite | workbench service | M11 | verified | | active side bar container (built-in or contributed, workbench/view_containers.rs) and active panel view (workbench.panelpart.activepanelid), open and close per location; panel view containers move between the panel and the secondary side bar by drag and drop (`moveViewContainerToLocation`, `views.customizations`; cargo test -p app a_panel_view_dropped_on_the_secondary_side_bar, ui-pair port/results/layout.md); no moving side bar containers or single views; ui-pair port/results/references-view.md and problems.md; active side bar view and active panel view (workbench.panelpart.activepanelid) only; no view container registry; verified: ui-pair port/results/references-view.md and problems.md (milestone 11 verification) |+| workbench/services/panecomposite | workbench service | M11 | verified | | active side bar container (built-in or contributed, workbench/view_containers.rs) and active panel view (workbench.panelpart.activepanelid), open and close per location; panel view containers move between the panel and the secondary side bar by drag and drop (`moveViewContainerToLocation`, `views.customizations`; cargo test -p app a_panel_view_dropped_on_the_secondary_side_bar, ui-pair port/results/layout.md); side bar containers and single views move by drag and drop too: a view dropped on a bar item gets a new container at the drop position, a container dropped on a pane merges its views beside it (cargo test -p app a_view_dropped_on_a_bar_item a_container_dropped_on_a_pane a_header_dropped_on_a_panel_view_shown_alone outline_header_dragged_onto; ui-pair port/fixtures/ui-steps/dnd-1.json to dnd-4.json with `workbench.activityBar.location: top`); ui-pair port/results/references-view.md and problems.md; active side bar view and active panel view (workbench.panelpart.activepanelid) only; no view container registry; verified: ui-pair port/results/references-view.md and problems.md (milestone 11 verification) || workbench/services/path | workbench service | M12 | verified | | the user home is $HOME (path_label, tildify), hasValidBasename is file_actions.rs is_valid_basename (cargo test -p app validates_file_names); pathService.test.ts covers only remote path semantics (no remote); verified at port-m12b-verify: cargo test -p app validates_file_names 1/1 || workbench/services/policies | workbench service | M10 | removed | | account policies, managed chat settings, the organization support link and policy telemetry need sign-in, AI or telemetry, none of which the port has by decision (port/notes.md); system policies are the platform/policy row || workbench/services/power | workbench service | M19 | verified | | workbench/power.rs: suspend, resume, shutdown, lock, unlock, thermal, battery and speed limit events to ExtHostPower; port/tools/shell-check (port/fixtures/extensions/shell-tests, 6/6); cargo test -p app power |