Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(views): move containers from item menus and by dragging items

rokarturfccc76ad75d7
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index 380af56f2fe..ec396e29f07 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -1553,7 +1553,7 @@ impl Workbench {
let items: Vec<_> = containers.map(|(icon, _, title, command, view)| {
let active = view.is_some_and(|view| self.side_bar_view == view) && self.side_bar_visible();
let icon = if active { self.active_view_icon(icon) } else { self.icon(icon, 36., 24., inactive) };
- self.action_bar_item("activity", command, icon.id(command), cx)
+ self.activity_composite_item(self.action_bar_item("activity", command, icon.id(command), cx), command, title, cx)
.debug_selector(move || command.to_owned())
.cursor_pointer()
.child(self.action_hover(title, command, hover))
@@ -1605,6 +1605,8 @@ impl Workbench {
))
// 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 `CompositeDragAndDrop.drop` of a composite from another bar: it moves here and opens.
+ .on_drop(cx.listener(|workbench, dragged: &panel::DraggedComposite, window, cx| workbench.move_view_container(dragged.id, layout::Part::SideBar, window, 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, action_bar::TabOrder { previous: vec!["activity"], next: Vec::new() }, div().child(self.action_bar_item("global-activity", "manage",
self.icon(self.manage_activity_icon(), 36., 24., inactive)
@@ -1646,7 +1648,7 @@ impl Workbench {
let active = self.side_bar_view == SideBarView::Testing && self.side_bar_visible();
let icon = if active { self.active_view_icon("beaker") } else { self.icon("beaker", 36., 24., inactive) };
let command = "workbench.view.testing";
- Some(self.action_bar_item("activity", command, icon.id(command), cx).cursor_pointer().child(self.action_hover("Testing", command, hover)).on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| workbench.activity_item_clicked(active, command, event, window, cx))))
+ Some(self.activity_composite_item(self.action_bar_item("activity", command, icon.id(command), cx), command, "Testing", cx).cursor_pointer().child(self.action_hover("Testing", command, hover)).on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| workbench.activity_item_clicked(active, command, event, window, cx))))
}
/// The checked view: a 32px rounded indicator behind the icon (activityaction.css); High Contrast
diff --git a/native/crates/app/src/workbench/action_bar.rs b/native/crates/app/src/workbench/action_bar.rs
index 0f7671d381b..656b65fab47 100644
--- a/native/crates/app/src/workbench/action_bar.rs
+++ b/native/crates/app/src/workbench/action_bar.rs
@@ -86,6 +86,12 @@ impl Workbench {
self.action_bars.drawn.borrow_mut().insert(bar, Vec::new());
}
+ /// Where the last frame drew the bar's item `key`.
+ pub(super) fn drawn_action_bar_item_bounds(&self, bar: &'static str, key: &str, cx: &App) -> Bounds<Pixels> {
+ let focus = self.action_bar_focus(bar, key, cx);
+ self.action_bars.drawn.borrow()[bar].iter().find(|item| item.focus == focus).expect("an item the last frame drew").bounds
+ }
+
/// The bar's items the last frame drew, in their order.
pub(super) fn drawn_action_bar_items(&self, bar: &'static str) -> Vec<FocusHandle> {
self.action_bars.drawn.borrow().get(bar).map(|items| items.iter().map(|item| item.focus.clone()).collect()).unwrap_or_default()
diff --git a/native/crates/app/src/workbench/activity_bar_menu.rs b/native/crates/app/src/workbench/activity_bar_menu.rs
index 359a1274d00..3bdbef08d3c 100644
--- a/native/crates/app/src/workbench/activity_bar_menu.rs
+++ b/native/crates/app/src/workbench/activity_bar_menu.rs
@@ -4,12 +4,15 @@
use std::collections::HashMap;
-use gpui::{Bounds, Context, Pixels, Point, Window};
+use gpui::{AppContext, Bounds, Context, Div, InteractiveElement, MouseButton, MouseDownEvent, Pixels, Point, Stateful, StatefulInteractiveElement, Window};
use serde_json::{Value, json};
use super::Workbench;
+use super::layout::Part;
+use super::panel::DraggedComposite;
use super::search_view::SideBarView;
use super::side_bar::VIEW_CONTAINERS;
+use super::view_locations::{TESTING_CONTAINER, location_code};
use crate::commands::Outcome;
use crate::menus::{MenuAction, MenuId, menu_actions};
@@ -18,6 +21,20 @@ const PINNED_CONTAINERS_KEY: &str = "workbench.activity.pinnedViewlets2";
/// globalCompositeBar.ts `ACCOUNTS_VISIBILITY_PREFERENCE_KEY`.
const ACCOUNTS_VISIBILITY_KEY: &str = "workbench.activity.showAccounts";
const TOGGLE_PINNED_PREFIX: &str = "workbench.action.activityBar.togglePinned.";
+/// paneCompositeBar.ts `moveViewContainerTo${location}` and `resetLocationAction`, run with the item's id
+/// (`getActionsContext`).
+const MOVE_CONTAINER_PREFIX: &str = "moveViewContainerTo";
+const RESET_LOCATION: &str = "resetLocationAction";
+/// The Testing activity item's id, its open command; its container is `TESTING_CONTAINER`.
+const TESTING_ITEM: &str = "workbench.view.testing";
+
+fn composite_container(item: &'static str) -> &'static str {
+ if item == TESTING_ITEM { TESTING_CONTAINER } else { item }
+}
+
+fn composite_arg(args: &[Value]) -> Option<&'static str> {
+ args.first().and_then(Value::as_str).map(super::tree_view::static_id)
+}
impl Workbench {
/// The containers the activity bar can show (`visibleItems`), pinned or not, in its order: id and title.
@@ -46,6 +63,13 @@ impl Workbench {
pub(super) fn show_activity_bar_context_menu(&mut self, position: Point<Pixels>, window: &mut Window, cx: &mut Context<Self>) {
let context = self.key_context(window);
+ let (actions, keybinding_commands) = self.activity_bar_menu_actions(&context);
+ self.show_context_menu_with_keybindings(actions, &keybinding_commands, &context, Bounds::new(position, Default::default()), Vec::new(), window, cx);
+ }
+
+ /// compositeBar.ts `getContextMenuActions` with activitybarPart.ts `fillContextMenuActions`, and the commands whose
+ /// keybindings the container items show.
+ fn activity_bar_menu_actions(&mut self, context: &HashMap<String, Value>) -> (Vec<MenuAction>, HashMap<String, String>) {
let containers = self.activity_bar_containers();
let unpinned = self.unpinned_containers();
let pinned_count = containers.iter().filter(|(id, _)| !unpinned.iter().any(|other| other == id)).count();
@@ -68,7 +92,7 @@ impl Workbench {
let accounts_visible = self.profile_storage.lock().unwrap().get(ACCOUNTS_VISIBILITY_KEY) == Some("true");
actions.push(MenuAction::Command { id: "toggleAccountsVisibility".into(), title: "Accounts".into(), enabled: true, checked: accounts_visible, alt: None });
actions.push(MenuAction::Separator);
- let position_actions = menu_actions(&self.menus, MenuId::ActivityBarPositionMenu, &context).into_iter().filter(|action| !matches!(action, MenuAction::Separator)).collect();
+ let position_actions = menu_actions(&self.menus, MenuId::ActivityBarPositionMenu, context).into_iter().filter(|action| !matches!(action, MenuAction::Separator)).collect();
actions.push(MenuAction::Submenu { title: "Activity Bar Position".into(), actions: position_actions, checked: false });
if self.setting("workbench.activityBar.location") == "default" {
let compact = self.setting("workbench.activityBar.compact") == true;
@@ -79,10 +103,90 @@ impl Workbench {
let side_bar_right = self.arrangement().side_bar == super::layout::Position::Right;
let title = if side_bar_right { "Move Primary Side Bar Left" } else { "Move Primary Side Bar Right" };
actions.push(MenuAction::Command { id: "workbench.action.toggleSidebarPosition".into(), title: title.into(), enabled: true, checked: false, alt: None });
- self.show_context_menu_with_keybindings(actions, &keybinding_commands, &context, Bounds::new(position, Default::default()), window, cx);
+ (actions, keybinding_commands)
+ }
+
+ /// compositeBarActions.ts `CompositeActionViewItem.showContextMenu` of an activity bar item (`part` the side bar)
+ /// or a panel tab: paneCompositeBar.ts `getContextMenuActionsForComposite` (Move To, Reset Location), then the
+ /// bar's own menu, anchored below the item's middle. `item` is the activity item's id, the container's but for
+ /// Testing's.
+ pub(super) fn show_composite_context_menu(&mut self, item: &'static str, part: Part, item_bounds: Bounds<Pixels>, window: &mut Window, cx: &mut Context<Self>) {
+ let context = self.key_context(window);
+ let container = composite_container(item);
+ let command = |id: &str, title: String| MenuAction::Command { id: id.into(), title, enabled: true, checked: false, alt: None };
+ let mut actions = Vec::new();
+ let current = self.container_location(container);
+ let default = self.default_container_location(container);
+ let moves = [(Part::SideBar, "Primary Side Bar"), (Part::AuxiliaryBar, "Secondary Side Bar"), (Part::Panel, "Panel")]
+ .into_iter()
+ .filter(|(location, _)| *location != current)
+ .map(|(location, label)| command(&format!("{MOVE_CONTAINER_PREFIX}{}", location_code(location)), label.into()))
+ .collect();
+ actions.push(MenuAction::Submenu { title: "Move To".into(), actions: moves, checked: false });
+ if default != current || self.view_to_reset(container).is_some() {
+ actions.push(command(RESET_LOCATION, "Reset Location".into()));
+ }
+ let mut keybinding_commands = HashMap::new();
+ // shortcut: the panel's and secondary side bar's own menus (panelPart.ts `fillExtraContextMenuActions`) are a
+ // ledger gap of workbench/services/views.
+ if part == Part::SideBar {
+ let (bar_actions, bar_keybindings) = self.activity_bar_menu_actions(&context);
+ actions.push(MenuAction::Separator);
+ actions.extend(bar_actions);
+ keybinding_commands = bar_keybindings;
+ }
+ let anchor = Point::new(item_bounds.center().x.floor(), item_bounds.bottom());
+ self.show_context_menu_with_keybindings(actions, &keybinding_commands, &context, Bounds::new(anchor, Default::default()), vec![json!(item)], window, cx);
+ }
+
+ /// compositeBarActions.ts `CompositeActionViewItem` of `bar`'s item `id` in `part`: its context menu.
+ pub(super) fn with_composite_menu(&self, item: Stateful<Div>, bar: &'static str, id: &'static str, part: Part, cx: &mut Context<Self>) -> Stateful<Div> {
+ item.on_mouse_down(MouseButton::Right, cx.listener(move |workbench, _: &MouseDownEvent, window, cx| {
+ cx.stop_propagation();
+ let bounds = workbench.drawn_action_bar_item_bounds(bar, id, cx);
+ workbench.show_composite_context_menu(id, part, bounds, window, cx);
+ }))
+ }
+
+ /// An activity bar item with its context menu and its drag as a `composite`, which the panel and the secondary
+ /// side bar take.
+ pub(super) fn activity_composite_item(&self, item: Stateful<Div>, id: &'static str, title: &'static str, cx: &mut Context<Self>) -> Stateful<Div> {
+ let dragged = DraggedComposite { id: composite_container(id), label: title.into(), foreground: self.color("modernActivityBarItem.activeForeground"), background: self.color("modernActivityBar.background") };
+ self.with_composite_menu(item, "activity", id, Part::SideBar, cx).on_drag(dragged, |dragged, _, _, cx| cx.new(|_| dragged.clone()))
+ }
+
+ /// paneCompositeBar.ts: a container at its default location with one view whose default container is another
+ /// (a generated one) resets that view.
+ fn view_to_reset(&self, container: &str) -> Option<super::view_locations::MovableView> {
+ match self.views_in(container)[..] {
+ [view] if view.default_container != container => Some(view),
+ _ => None,
+ }
}
pub(super) fn register_activity_bar_context_menu_commands(&mut self) {
+ for part in [Part::SideBar, Part::Panel, Part::AuxiliaryBar] {
+ self.commands.register(format!("{MOVE_CONTAINER_PREFIX}{}", location_code(part)), move |workbench, args, window, cx| {
+ if let Some(container) = composite_arg(&args).map(composite_container) {
+ workbench.move_view_container(container, part, window, cx);
+ }
+ Outcome::done()
+ });
+ }
+ self.commands.register(RESET_LOCATION, |workbench, args, window, cx| {
+ let Some(container) = composite_arg(&args).map(composite_container) else { return Outcome::done() };
+ let default = workbench.default_container_location(container);
+ if workbench.container_location(container) != default {
+ workbench.move_view_container(container, default, window, cx);
+ } else if let Some(view) = workbench.view_to_reset(container) {
+ workbench.move_view_to_container(view.id, view.default_container, cx);
+ // `openViewContainer(viewContainer.id)` finds nothing once a generated container is cleaned up.
+ if !super::view_locations::is_generated_container(container) {
+ workbench.show_view_container(container, cx);
+ }
+ }
+ Outcome::done()
+ });
self.commands.register("toggleAccountsVisibility", |workbench, _, _, cx| {
let mut storage = workbench.profile_storage.lock().unwrap();
let visible = storage.get(ACCOUNTS_VISIBILITY_KEY) == Some("true");
@@ -148,11 +252,13 @@ mod tests {
use crate::theme::load_theme;
use crate::workbench::Workbench;
- fn right_click_explorer_icon(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext) -> Vec<(String, bool, bool, Option<String>)> {
+ /// Right-clicks the bar below its items, as activity-bar-menu.json does; an item shows its own menu.
+ fn right_click_activity_bar(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext) -> Vec<(String, bool, bool, Option<String>)> {
cx.update(|window, cx| drop(window.draw(cx)));
- let icon = cx.debug_bounds("workbench.view.explorer").expect("the Explorer icon").center();
- cx.simulate_mouse_down(icon, MouseButton::Right, Modifiers::none());
- cx.simulate_mouse_up(icon, MouseButton::Right, Modifiers::none());
+ let icon = cx.debug_bounds("workbench.view.explorer").expect("the Explorer icon");
+ let below = gpui::point(icon.center().x, icon.bottom() + gpui::px(400.));
+ cx.simulate_mouse_down(below, MouseButton::Right, Modifiers::none());
+ cx.simulate_mouse_up(below, MouseButton::Right, Modifiers::none());
cx.run_until_parked();
let items = workbench.read_with(cx, |workbench, _| {
let menu = workbench.context_menu.as_ref().expect("a context menu shows");
@@ -188,20 +294,20 @@ mod tests {
let separator = ("---".to_owned(), false, false, None);
let rest = [separator.clone(), item("Accounts", false, None), separator, item("Activity Bar Position >", false, None), item("Activity Bar Size >", false, None), item("Move Primary Side Bar Right", false, None)];
let containers = [item("Explorer", true, Some("⇧⌘E")), item("Search", true, Some("⇧⌘F")), item("Source Control", true, Some("⌃⇧G")), item("Run and Debug", true, Some("⇧⌘D")), item("Extensions", true, Some("⇧⌘X"))];
- assert_eq!(right_click_explorer_icon(&workbench, cx), [containers.as_slice(), rest.as_slice()].concat());
+ assert_eq!(right_click_activity_bar(&workbench, cx), [containers.as_slice(), rest.as_slice()].concat());
workbench.update_in(cx, |workbench, window, cx| {
let _ = workbench.execute_command("workbench.action.activityBar.togglePinned.workbench.view.search", Vec::new(), window, cx);
});
cx.update(|window, cx| drop(window.draw(cx)));
assert!(cx.debug_bounds("workbench.view.search").is_none(), "an unpinned container leaves the bar");
- assert_eq!(right_click_explorer_icon(&workbench, cx)[1], item("Search", false, Some("⇧⌘F")));
+ assert_eq!(right_click_activity_bar(&workbench, cx)[1], item("Search", false, Some("⇧⌘F")));
for id in ["workbench.view.scm", "workbench.view.debug", "workbench.view.extensions"] {
workbench.update_in(cx, |workbench, window, cx| {
let _ = workbench.execute_command(&format!("workbench.action.activityBar.togglePinned.{id}"), Vec::new(), window, cx);
});
}
- assert_eq!(right_click_explorer_icon(&workbench, cx)[0], ("Explorer".to_owned(), false, true, Some("⇧⌘E".to_owned())), "the last pinned container stays");
+ assert_eq!(right_click_activity_bar(&workbench, cx)[0], ("Explorer".to_owned(), false, true, Some("⇧⌘E".to_owned())), "the last pinned container stays");
}
}
diff --git a/native/crates/app/src/workbench/context_menu.rs b/native/crates/app/src/workbench/context_menu.rs
index 109e8e5f7bf..231e7d00ead 100644
--- a/native/crates/app/src/workbench/context_menu.rs
+++ b/native/crates/app/src/workbench/context_menu.rs
@@ -86,8 +86,9 @@ impl Workbench {
/// `keybinding_commands` maps an item's command to the command whose keybinding it shows, as compositeBar.ts's
/// pin toggles carry their view container's id.
- pub(super) fn show_context_menu_with_keybindings(&mut self, actions: Vec<MenuAction>, keybinding_commands: &HashMap<String, String>, context: &HashMap<String, Value>, anchor: Bounds<Pixels>, window: &mut Window, cx: &mut Context<Self>) {
- self.show_context_menu_aligned(actions, keybinding_commands, context, anchor, Vec::new(), LayoutAnchorPosition::Before, window, cx);
+ #[allow(clippy::too_many_arguments, reason = "the menu, its keybindings, context, anchor and arguments")]
+ pub(super) fn show_context_menu_with_keybindings(&mut self, actions: Vec<MenuAction>, keybinding_commands: &HashMap<String, String>, context: &HashMap<String, Value>, anchor: Bounds<Pixels>, args: Vec<Value>, window: &mut Window, cx: &mut Context<Self>) {
+ self.show_context_menu_aligned(actions, keybinding_commands, context, anchor, args, LayoutAnchorPosition::Before, window, cx);
}
/// A toolbar's dropdown with `AnchorAlignment.RIGHT`: the menu's right edge at the button's.
diff --git a/native/crates/app/src/workbench/panel.rs b/native/crates/app/src/workbench/panel.rs
index 5cd93cac468..6bf798408d5 100644
--- a/native/crates/app/src/workbench/panel.rs
+++ b/native/crates/app/src/workbench/panel.rs
@@ -101,10 +101,10 @@ type TabLayoutKey = (Pixels, Vec<&'static str>, Option<&'static str>, bool);
/// A composite bar tab being dragged (`CompositeDragAndDropData` of type `composite`), drawn as its label.
#[derive(Clone)]
pub(super) struct DraggedComposite {
- id: &'static str,
- label: SharedString,
- foreground: Rgba,
- background: Rgba,
+ pub id: &'static str,
+ pub label: SharedString,
+ pub foreground: Rgba,
+ pub background: Rgba,
}
impl Render for DraggedComposite {
@@ -417,7 +417,10 @@ impl Workbench {
let mut overflowing = Vec::new();
for tab in self.part_tabs(part) {
match shown.contains(&tab.id) {
- true => tabs.push(self.action_bar_item(tabs_bar, tab.id, self.panel_tab(&tab, Some(tab.id) == active, tabs.is_empty(), background, window, cx), cx).into_any_element()),
+ true => {
+ let item = self.action_bar_item(tabs_bar, tab.id, self.panel_tab(&tab, Some(tab.id) == active, tabs.is_empty(), background, window, cx), cx);
+ tabs.push(self.with_composite_menu(item, tabs_bar, tab.id, part, cx).into_any_element());
+ }
false => overflowing.push(MenuAction::Command { id: format!("{}.focus", tab.view), title: panel_tab_label(&tab, self), enabled: true, checked: Some(tab.id) == active, alt: None }),
}
}
diff --git a/native/crates/app/src/workbench/view_containers.rs b/native/crates/app/src/workbench/view_containers.rs
index 62ac35f34f8..2f157bd7d9c 100644
--- a/native/crates/app/src/workbench/view_containers.rs
+++ b/native/crates/app/src/workbench/view_containers.rs
@@ -327,7 +327,7 @@ impl Workbench {
}
};
let title: &'static str = static_id(&container.title);
- items.push(self.action_bar_item("activity", id, icon.id(id), cx).relative().children(self.container_activity_badge(id)).cursor_pointer().child(self.action_hover(title, id, hover)).on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| workbench.activity_item_clicked(active, id, event, window, cx))));
+ items.push(self.activity_composite_item(self.action_bar_item("activity", id, icon.id(id), cx), id, title, cx).relative().children(self.container_activity_badge(id)).cursor_pointer().child(self.action_hover(title, id, hover)).on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| workbench.activity_item_clicked(active, id, event, window, cx))));
}
items
}
diff --git a/native/crates/app/src/workbench/view_locations.rs b/native/crates/app/src/workbench/view_locations.rs
index 966d26b36f2..9acf19c438d 100644
--- a/native/crates/app/src/workbench/view_locations.rs
+++ b/native/crates/app/src/workbench/view_locations.rs
@@ -380,7 +380,7 @@ impl Workbench {
let view = self.generated_container_view(id).expect("a container with a view");
let active = self.side_bar_view == SideBarView::Generated(id) && self.is_part_visible(Part::SideBar);
let icon = if active { self.active_view_icon(view.icon) } else { self.icon(view.icon, 36., 24., inactive) };
- items.push(self.action_bar_item("activity", id, icon.id(id), cx).relative().cursor_pointer().child(self.action_hover(view.name, id, hover)).on_click(cx.listener(move |workbench, event: &ClickEvent, _, cx| workbench.generated_activity_item_clicked(active, id, event, cx))));
+ items.push(self.activity_composite_item(self.action_bar_item("activity", id, icon.id(id), cx), id, view.name, cx).relative().cursor_pointer().child(self.action_hover(view.name, id, hover)).on_click(cx.listener(move |workbench, event: &ClickEvent, _, cx| workbench.generated_activity_item_clicked(active, id, event, cx))));
}
items
}
diff --git a/native/crates/app/src/workbench/view_locations/tests.rs b/native/crates/app/src/workbench/view_locations/tests.rs
index b639404f53a..d810df6197e 100644
--- a/native/crates/app/src/workbench/view_locations/tests.rs
+++ b/native/crates/app/src/workbench/view_locations/tests.rs
@@ -285,3 +285,96 @@ fn a_container_moves_between_the_side_bar_and_the_panel_and_keeps_its_location_o
restarted.update_in(window_cx, |workbench, window, cx| workbench.move_view_container(EXPLORER_CONTAINER, Part::SideBar, window, cx));
assert_eq!(stored(&profile)["viewContainerLocations"], json!({ "workbench.panel.output": 0 }));
}
+
+/// The open context menu's root: each command's title and id, and a submenu as "{title} >" with its titles.
+fn context_menu(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext) -> (Vec<(String, String)>, Vec<Value>) {
+ workbench.read_with(cx, |workbench, _| {
+ let menu = workbench.context_menu.as_ref().expect("a context menu shows");
+ let items = menu.levels[0].actions.iter().map(|action| match action {
+ crate::menus::MenuAction::Command { id, title, .. } => (title.clone(), id.clone()),
+ crate::menus::MenuAction::Submenu { title, actions, .. } => {
+ let titles: Vec<_> = actions.iter().map(|action| match action {
+ crate::menus::MenuAction::Command { title, .. } => title.clone(),
+ _ => "---".into(),
+ }).collect();
+ (format!("{title} >"), titles.join(", "))
+ }
+ crate::menus::MenuAction::Separator => ("---".into(), String::new()),
+ });
+ (items.collect(), menu.args.clone())
+ })
+}
+
+fn right_click(selector: &'static str, cx: &mut VisualTestContext) {
+ cx.update(|window, cx| drop(window.draw(cx)));
+ let point = cx.debug_bounds(selector).unwrap().center();
+ cx.simulate_mouse_down(point, gpui::MouseButton::Right, gpui::Modifiers::none());
+ cx.simulate_mouse_up(point, gpui::MouseButton::Right, gpui::Modifiers::none());
+ cx.run_until_parked();
+}
+
+/// Runs the open menu's item `title` with the menu's arguments, as a click on it does.
+fn run_menu_item(workbench: &gpui::Entity<Workbench>, items: &[(String, String)], args: Vec<Value>, title: &str, cx: &mut VisualTestContext) {
+ let id = items.iter().find(|(item, _)| item == title).unwrap_or_else(|| panic!("{title} in {items:?}")).1.clone();
+ cx.simulate_keystrokes("escape");
+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command(&id, args, window, cx)));
+ cx.run_until_parked();
+}
+
+/// paneCompositeBar.ts `getContextMenuActionsForComposite`: an item's Move To lists the other locations, and Reset
+/// Location shows once its container left the default one.
+#[gpui::test]
+fn the_explorer_item_menu_moves_it_to_the_panel_and_its_tab_menu_resets_it(cx: &mut TestAppContext) {
+ let profile = Arc::new(Mutex::new(Storage::in_memory()));
+ let (workbench, cx) = open(profile.clone(), cx);
+ right_click(EXPLORER_CONTAINER, cx);
+ let (items, args) = context_menu(&workbench, cx);
+ assert_eq!(items[0], ("Move To >".to_string(), "Secondary Side Bar, Panel".to_string()));
+ assert_eq!(items[1].0, "---", "no Reset Location at the default location, then the activity bar's menu");
+ assert_eq!(args, [json!(EXPLORER_CONTAINER)]);
+ let move_to_panel = format!("moveViewContainerTo{}", location_code(Part::Panel));
+ cx.simulate_keystrokes("escape");
+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command(&move_to_panel, args, window, cx)));
+ cx.run_until_parked();
+ assert_eq!(stored(&profile)["viewContainerLocations"], json!({ EXPLORER_CONTAINER: 1 }));
+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.active_container_in(Part::Panel)), Some(EXPLORER_CONTAINER));
+
+ right_click("active-composite-tab", cx);
+ let (items, args) = context_menu(&workbench, cx);
+ assert_eq!(items[..2], [("Move To >".to_string(), "Primary Side Bar, Secondary Side Bar".to_string()), ("Reset Location".to_string(), "resetLocationAction".to_string())]);
+ assert_eq!(items.len(), 2, "the panel's own menu is not ported");
+ workbench.update(cx, |workbench, cx| workbench.hide_panel(cx));
+ run_menu_item(&workbench, &items, args, "Reset Location", cx);
+ assert_eq!(stored(&profile)["viewContainerLocations"], json!({}));
+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.side_bar_view), SideBarView::Explorer);
+}
+
+fn drag(from: gpui::Point<gpui::Pixels>, to: gpui::Point<gpui::Pixels>, cx: &mut VisualTestContext) {
+ cx.simulate_mouse_down(from, gpui::MouseButton::Left, gpui::Modifiers::none());
+ cx.simulate_mouse_move(from + gpui::point(gpui::px(10.), gpui::px(0.)), gpui::MouseButton::Left, gpui::Modifiers::none());
+ cx.simulate_mouse_move(to, gpui::MouseButton::Left, gpui::Modifiers::none());
+ cx.simulate_mouse_up(to, gpui::MouseButton::Left, gpui::Modifiers::none());
+ cx.run_until_parked();
+}
+
+/// compositeBar.ts `CompositeDragAndDrop.drop` of a `composite`: an activity item dropped on the secondary side bar
+/// moves its container there, and that bar's tab dropped on the activity bar moves it back.
+#[gpui::test]
+fn the_explorer_item_drags_to_the_secondary_side_bar_and_its_tab_back_to_the_activity_bar(cx: &mut TestAppContext) {
+ let profile = Arc::new(Mutex::new(Storage::in_memory()));
+ let (workbench, cx) = open(profile.clone(), cx);
+ workbench.update(cx, |workbench, cx| workbench.set_part_hidden(Part::AuxiliaryBar, false, cx));
+ cx.update(|window, cx| drop(window.draw(cx)));
+ let item = cx.debug_bounds(EXPLORER_CONTAINER).unwrap().center();
+ let title = cx.debug_bounds("pane-composite-title").unwrap().center();
+ drag(item, title, cx);
+ assert_eq!(stored(&profile)["viewContainerLocations"], json!({ EXPLORER_CONTAINER: 2 }));
+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.active_container_in(Part::AuxiliaryBar)), Some(EXPLORER_CONTAINER));
+
+ cx.update(|window, cx| drop(window.draw(cx)));
+ let tab = cx.debug_bounds("active-composite-tab").unwrap().center();
+ let search = cx.debug_bounds(SEARCH_CONTAINER).unwrap().center();
+ drag(tab, search, cx);
+ assert_eq!(stored(&profile)["viewContainerLocations"], json!({}));
+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.side_bar_view), SideBarView::Explorer);
+}
diff --git a/port/fixtures/ui-pair/contributed-panes.json b/port/fixtures/ui-pair/contributed-panes.json
index a06c5d4d481..e2ead0aa316 100644
--- a/port/fixtures/ui-pair/contributed-panes.json
+++ b/port/fixtures/ui-pair/contributed-panes.json
@@ -13,5 +13,13 @@
{ "shot": "palette" },
{ "key": "return" },
{ "wait": 1500 },
- { "shot": "panel" }
+ { "shot": "panel" },
+ { "rightClick": [26, 321], "foreground": true },
+ { "wait": 1500 },
+ { "shot": "item-menu" },
+ { "key": "escape", "foreground": true },
+ { "wait": 800 },
+ { "dragShot": [26, 321, 600, 505] },
+ { "wait": 1500 },
+ { "shot": "moved" }
]
diff --git a/port/ledger.md b/port/ledger.md
index 26497d0a4f9..7cae06e02e1 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -456,7 +456,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/services/userDataProfile | workbench service | M10 | verified | | one app-wide `UserDataProfilesService` (a gpui Global in app/src/user_data_profile.rs) for every window of the process: profile windows open in this process, a transient profile lives while a window runs it (userDataProfilesHandler.ts cleanup on close), and `onDidChangeProfiles` reaches every window (cargo test -p app workbench::user_data_profile: profile_windows_open_in_this_process, every_window_sees_a_profile_another_window_creates_and_removes); userDataProfileManagement.ts `switchProfile`, `removeProfile` and `changeCurrentProfile` (configuration, keybindings, global state and user extensions move to the profile's files, the extension host restarts, workbench/extension_host_restart.rs) in workbench/user_data_profile.rs; the configuration layers of a profile (`ApplicationConfiguration`, PROFILE_SCOPES, `workbench.settings.applyToAllProfiles`) with configurationService.test.ts's Profiles suite (cargo test -p config profile_tests); the settings, keybindings, tasks, snippets, globalState and extensions resources and the `.code-profile` template of userDataProfileImportExportService.ts as app/src/profile_template.rs (cargo test -p app profile_template); a template's extensions install the way extensionsResource.ts `apply` does, one publisher trust dialog for all of them and an error naming the ones that failed (cargo test -p app template_extensions_ask_for_publisher_trust_once); per-profile extensions.json (cargo test -p exthost extension_management); `createTroubleshootProfile` is removed with contrib/issue, its only caller (issueTroubleshoot.ts); profile templates from `profileTemplatesUrl` have no source, the product.json has none |
| workbench/services/userDataSync | workbench service | | removed | | no sign-in/AI by decision (port/notes.md); not ported |
| workbench/services/utilityProcess | workbench service | | verified | | no utility process workers: the file watcher worker, the one kept client, is files/src/watcher.rs on an FSEvents thread (platform/files; api-tests `vscode API - workspace-watcher` passes in the milestone 20 whole-suite run); localTranscription is AI, removed (port/notes.md milestone 20) |
-| workbench/services/views | workbench service | M11 | ported | [3 M] panel.rs:189: `move_view_container` moves any container between the side bar, secondary side bar and panel and keeps the location on restart, but nothing calls it for the primary side bar: the tabs' and activity bar items' context menu lacks "Move To" (Primary Side Bar, Secondary Side Bar, Panel) and "Reset Location" (paneCompositeBar.ts `getCompositeActions`), a container's tab cannot be dropped on the activity bar nor an activity item on the panel or secondary side bar (compositeBar.ts), and ui-pair `contributed-panes.json` has no move step; [3 S] view_locations.rs:225: the Extensions and Testing containers do not move (`can_move_container`) | view containers of `viewsContainers.activitybar` and `viewsContainers.panel` and the tree views of every container (workbench/view_containers.rs): activity bar items while a view's `when` holds, `workbench.view.extension.<id>` with its "View: Show <title>" Command Palette item while `viewContainer.<id>.enabled` (cargo test -p app an_extension_container_is_shown), a panel container's tab after the built-in ones, its views as side-by-side panes under its "..." and "View: Toggle <title>" (cargo test -p app an_extension_panel_container_is_a_panel_tab), each contributed view's "<container>: Focus on <view> View" palette item (ui-pair port/fixtures/ui-pair/contributed-panes.json "palette" and "panel" match the reference but its Ports tab, removed by decision), `<view id>.focus`, `<view id>.active`, merged single views, view_panes.rs panes for the views of an extension container and of Testing (`PaneContainer::Contributed`: cargo test -p app view_containers::; ui-pair port/fixtures/ui-pair/contributed-panes.json with port/fixtures/extensions/contributed-panes, the Port Panes and Testing side bars as the reference), treeView.ts `noDataProviderMessage` (cargo test -p app tree_view::), contributed views of scm and debug as panes of those containers; the Explorer's ViewDescriptorsState (view_panes.rs); ui-pair port/results/references-view.md; `visibility` (`hidden` views stay out until the Views submenu of the Explorer's "..." shows them, `collapsed`; workbench/view_visibility.rs: cargo test -p app view_visibility); the Explorer container's ViewDescriptorsState (view_panes.rs); moving views (workbench/view_locations.rs, verified): `views.customizations` viewLocations and generated containers `workbench.views.service.<location>.<uuid>` with their activity bar items and panel tabs, View: Move View, Move Focused View, Reset Focused View Location, a view header dropped on another container's pane (at its position), on the activity bar or on a panel's title (a new entry), `focusedView`; the folder view, Open Editors, Outline, Timeline, Source Control's Changes, Search, the debug views and the panel's views move into any built-in container or a new entry and back, the moved view opens focused, the picker lists only visible views, a moved view's hidden state is in its current container's state (cargo test -p app a_moved_view_is_hidden); cargo test -p app (2594 passed); ui-pair port/fixtures/ui-pair/m11/move-view.json, port/results/move-view.md (8 steps match, Ports removed by decision); verified: ui-pair port/results/references-view.md (milestone 11 verification) |
+| workbench/services/views | workbench service | M11 | ported | [3 S] activity_bar_menu.rs:113: an activity item's or tab's context menu lacks Configure Keybinding, Hide/Keep '{name}' and Show/Hide Badge above Move To (compositeBarActions.ts `showContextMenu`; ui-pair contributed-panes.json "item-menu"), and a panel or secondary side bar tab's menu lacks its bar's own actions (panelPart.ts `fillExtraContextMenuActions`); [3 S] panel.rs:189: a composite dropped on another bar goes to that bar's end, not the drop index (compositeBar.ts `getTargetIndex`), one dropped on its own bar does not reorder (`moveComposite`), and the moved container opens without focus (`openComposite(id, true)`; ui-pair contributed-panes.json "moved": the reference puts Port Panes before Terminal and focuses its first pane); [3 S] activity_bar_menu.rs:153: an activity item drags as its title, the reference as its icon; [3 S] side_bar.rs:62: the compact activity bar's tabs have no item menu and no drag; [3 S] view_panes.rs:535: a collapsed pane of a container in the panel draws expanded, the reference as a narrow strip (ui-pair contributed-panes.json "moved", Third); [3 S] panel.rs:553: after a composite drop the tab under the pointer shows its hover, the reference none (contributed-panes.json "moved"); [3 S] view_locations.rs:225: the Extensions and Testing containers do not move (`can_move_container`) | view containers of `viewsContainers.activitybar` and `viewsContainers.panel` and the tree views of every container (workbench/view_containers.rs): activity bar items while a view's `when` holds, `workbench.view.extension.<id>` with its "View: Show <title>" Command Palette item while `viewContainer.<id>.enabled` (cargo test -p app an_extension_container_is_shown), a panel container's tab after the built-in ones, its views as side-by-side panes under its "..." and "View: Toggle <title>" (cargo test -p app an_extension_panel_container_is_a_panel_tab), each contributed view's "<container>: Focus on <view> View" palette item (ui-pair port/fixtures/ui-pair/contributed-panes.json "palette" and "panel" match the reference but its Ports tab, removed by decision), `<view id>.focus`, `<view id>.active`, merged single views, view_panes.rs panes for the views of an extension container and of Testing (`PaneContainer::Contributed`: cargo test -p app view_containers::; ui-pair port/fixtures/ui-pair/contributed-panes.json with port/fixtures/extensions/contributed-panes, the Port Panes and Testing side bars as the reference), treeView.ts `noDataProviderMessage` (cargo test -p app tree_view::), contributed views of scm and debug as panes of those containers; the Explorer's ViewDescriptorsState (view_panes.rs); ui-pair port/results/references-view.md; `visibility` (`hidden` views stay out until the Views submenu of the Explorer's "..." shows them, `collapsed`; workbench/view_visibility.rs: cargo test -p app view_visibility); the Explorer container's ViewDescriptorsState (view_panes.rs); moving views (workbench/view_locations.rs, verified): `views.customizations` viewLocations and generated containers `workbench.views.service.<location>.<uuid>` with their activity bar items and panel tabs, View: Move View, Move Focused View, Reset Focused View Location, a view header dropped on another container's pane (at its position), on the activity bar or on a panel's title (a new entry), `focusedView`; the folder view, Open Editors, Outline, Timeline, Source Control's Changes, Search, the debug views and the panel's views move into any built-in container or a new entry and back, the moved view opens focused, the picker lists only visible views, a moved view's hidden state is in its current container's state (cargo test -p app a_moved_view_is_hidden); an activity item's and a tab's context menu with Move To (the other locations) and Reset Location away from the default location or for a lone view at home (paneCompositeBar.ts `getContextMenuActionsForComposite`: cargo test -p app the_explorer_item_menu), an activity item dragged onto the panel or secondary side bar and a tab dropped on the activity bar (compositeBar.ts `CompositeDragAndDrop.drop`: cargo test -p app the_explorer_item_drags; ui-pair contributed-panes.json "moved": Port Panes moves into the panel and opens in both); cargo test -p app (2594 passed); ui-pair port/fixtures/ui-pair/m11/move-view.json, port/results/move-view.md (8 steps match, Ports removed by decision); verified: ui-pair port/results/references-view.md (milestone 11 verification) |
| workbench/services/workingCopy | workbench service | M8 | verified | | the text file and untitled working copies are the editor models (dirty state, save, revert, the window's edited dot of `onDidChangeDirty`): cargo test -p app untitled (30), lifecycle (3); WorkingCopyFileService create, move, copy, delete with participants: cargo test -p files operations (12); WorkingCopyHistoryService and its tracker for saves into User/History, entries following renames and folder moves (`moveEntries`): cargo test -p app local_history (10); WorkingCopyBackupService and the backup tracker with hot exit (backups.rs, workbench/backup_tracker.rs), a backup of a deleted file restoring as an orphaned model (`doResolveFromBackup`), modified scratchpads backing up: cargo test -p app backup (19); the working copies of editable custom documents (MainThreadCustomEditorModel, workbench/custom_documents.rs: `$onDidEdit` edits for undo and redo with `$disposeEdits`, `$onContentChange`, dirty tabs, `$onSave`, Save As with `$onSaveAs` and the editor moved to the target, `$revert`, `$backup` into a `vscode-custom-editor` backup restored with its backup id): cargo test -p app custom_documents (3), and port/fixtures/extensions/custom-document-tests (FIXTURE=custom-document-tests port/tools/webview-check: 4/4 in the reference and 4/4 in the port). Notebook working copies are the contrib/notebook row's; their backups are typed (`hashIdentifier` with a type id, backups.rs: cargo test -p app backups::, the upstream typed hashes) and the shutdown joins backups still being written |
| workbench/services/workspaces | workbench service | M12 | ported | [3 L] workspace_editing.rs:243, :379: enterWorkspace reopens the window where upstream switches in place (L); the Remove Folder picker has no ROOT_FOLDER icons (S) | workspace_trust.rs: WorkspaceTrustManagementService (uriTrustInfo in shared storage, longest trusted parent, empty window memento, parent folder trust) and WorkspaceTrustRequestService: cargo test -p app workspace_trust; workbench/workspace_editing.rs: abstractWorkspaceEditingService.ts addFolders, removeFolders, updateFolders, saveAndEnterWorkspace, enterWorkspace (shortcut in port/notes.md: the window reopens in place), duplicate workspace: cargo test -p app folders_added_and_removed_in_a_workspace_reach_its_file_the_explorer_settings_and_host workspace_editing; ui-pair port/fixtures/ui-pair/m12/workspace-folders.json, verified at port-m12b-verify |
| workbench/contrib/accessibility | workbench contribution | M19 | verified | | workbench/accessible_view.rs and workbench/accessibility.rs: accessible view and accessibility help (Alt+F2, Alt+F1 with the editor, hover, view help providers, the hover's and a workbench hover's accessible view, Escape from the latter focusing the hover again, a focused contributed tree or webview view's `accessibilityHelpContent`, a webview view the `focusedView` while its webview has the keyboard; Alt+F6, Alt+H, Alt+K, Alt+A, Alt+]/[), notification aria labels with the verbosity hint, unfocused editor dimming, Toggle Screen Reader Accessibility Mode, status entry; cargo test -p app accessib (alt_f1_shows_the_editor_help..., alt_f1_in_a_contributed_view..., alt_f1_in_a_webview_view..., dimming), cargo test -p app content_hover (the hover's accessible view), port/tools/a11y-check reads the help text area (port/notes.md milestone 19) |