Visual Studio Code, rebuilt in Rust
Rust
fix(scm): leave the inline group out of row context menus
rokarturadba6ba4c751
diff --git a/native/crates/app/src/workbench/scm_actions.rs b/native/crates/app/src/workbench/scm_actions.rsindex 7c479fc1dec..f9ec0de6071 100644--- a/native/crates/app/src/workbench/scm_actions.rs+++ b/native/crates/app/src/workbench/scm_actions.rs@@ -471,7 +471,8 @@ impl Workbench {let others = selection.iter().filter(|&&handle| handle != provider.handle).filter_map(|&handle| self.scm.model.provider(handle));args.extend(others.map(Self::provider_arg));}- self.show_context_menu(MenuId::ScmSourceControl, &context, Bounds::new(position, Default::default()), args, window, cx);+ let actions = crate::menus::menu_group_actions(&self.menus, MenuId::ScmSourceControl, &context, |group| group != "inline");+ self.show_context_menu_actions(actions, &context, Bounds::new(position, Default::default()), args, window, cx);}/// `scm.graphView.viewMode` in workspace storage, `scm.defaultViewMode` when unset (`_getViewMode`).diff --git a/native/crates/app/src/workbench/scm_actions/tests.rs b/native/crates/app/src/workbench/scm_actions/tests.rsindex 122e6e2d9a5..6a71afec203 100644--- a/native/crates/app/src/workbench/scm_actions/tests.rs+++ b/native/crates/app/src/workbench/scm_actions/tests.rs@@ -299,6 +299,43 @@ fn a_folder_row_shows_the_resource_folder_menu_with_its_resources(cx: &mut TestA});}+/// scmViewPane.ts `onListContextMenu` and util.ts `collectContextMenuActions`: a repository, resource group or+/// resource row's menu drops the `inline` group its row shows as buttons.+#[gpui::test]+fn row_context_menus_leave_out_the_inline_group(cx: &mut TestAppContext) {+ use crate::menus::{Entry, MenuItem};+ let (workbench, _receiver, cx) = workbench_in("scm-row-menus", cx);+ cx.simulate_resize(gpui::size(gpui::px(1024.), gpui::px(768.)));+ request(&workbench, cx, "$registerSourceControl", register(0, "/w/repo"));+ request(&workbench, cx, "$registerSourceControl", register(1, "/w/other"));+ let raw = json!([1, { "scheme": "file", "path": "/w/repo/a.ts" }, [null, null], "Modified", false, false, "", null, null, null]);+ request(&workbench, cx, "$registerGroups", vec![json!(0), json!([[2, "workingTree", "Changes", {}, false]]), json!([[2, [[0, 0, [raw]]]]])]);+ workbench.update_in(cx, |workbench, window, cx| {+ for menu in [MenuId::ScmSourceControl, MenuId::ScmResourceGroupContext, MenuId::ScmResourceStateContext] {+ for (id, group) in [("git.stage", "1_modification"), ("git.clean", "inline")] {+ workbench.menus.push(MenuItem { menu, entry: Entry::Command { id: id.into(), precondition: None, toggled: None, alt: None }, title: id.into(), group: group.into(), order: 0., when: None });+ }+ }+ drop(workbench.execute_command("workbench.view.scm", Vec::new(), window, cx));+ workbench.set_part_hidden(crate::workbench::layout::Part::SideBar, false, cx);+ });+ cx.run_until_parked();+ for row in ["scm-repository-0", "scm-group-0-2", "scm-resource-0-2-1"] {+ let center = cx.debug_bounds(row).unwrap_or_else(|| panic!("the view shows {row}")).center();+ cx.simulate_mouse_down(center, gpui::MouseButton::Right, gpui::Modifiers::none());+ cx.run_until_parked();+ workbench.update(cx, |workbench, cx| {+ cx.notify();+ let menu = workbench.context_menu.take().unwrap_or_else(|| panic!("{row} opens its menu"));+ let ids: Vec<&str> = menu.levels[0].actions.iter().filter_map(|action| match action {+ MenuAction::Command { id, .. } => Some(id.as_str()),+ _ => None,+ }).collect();+ assert!(ids.contains(&"git.stage") && !ids.contains(&"git.clean"), "{row}: {ids:?}");+ });+ }+}+/// scmHistoryViewPane.ts `_onContextMenu`: each `scm/historyItemRef/context` command the item's refs show is a/// submenu of those refs, grouped by category, and an entry runs the command with the ref id last.#[gpui::test]diff --git a/native/crates/app/src/workbench/scm_view.rs b/native/crates/app/src/workbench/scm_view.rsindex ab1ada5e9f5..eb8e8694517 100644--- a/native/crates/app/src/workbench/scm_view.rs+++ b/native/crates/app/src/workbench/scm_view.rs@@ -693,6 +693,7 @@ impl Workbench {let selected = self.scm.focused == Some(handle) && repository_count > 1;div().id(gpui::SharedString::from(format!("scm-repository-{handle}")))+ .debug_selector(move || format!("scm-repository-{handle}")).h(px(ROW_HEIGHT)).pr(px(12.)).flex()@@ -978,7 +979,7 @@ impl Workbench {let menu_args = vec![Self::group_arg(provider, group)];div().id(id.clone())- .group(id.clone())+ .debug_selector(|| id.to_string()).h(px(ROW_HEIGHT))// abstractTree.ts `indentSize`: the twistie 8px further in than the input row's and the actions, and the// label after the twistie's 6px padding (tree.css), measured against the reference with ui-pair.@@ -998,7 +999,8 @@ impl Workbench {cx.notify();})).on_mouse_down(MouseButton::Right, cx.listener(move |workbench, event: &MouseDownEvent, window, cx| {- workbench.show_context_menu(MenuId::ScmResourceGroupContext, &menu_context, Bounds::new(event.position, Default::default()), menu_args.clone(), window, cx);+ let actions = crate::menus::menu_group_actions(&workbench.menus, MenuId::ScmResourceGroupContext, &menu_context, |group| group != "inline");+ workbench.show_context_menu_actions(actions, &menu_context, Bounds::new(event.position, Default::default()), menu_args.clone(), window, cx);})).child(self.icon(if collapsed { "chevron-right" } else { "chevron-down" }, TWISTIE, 16., foreground)).child(div().flex_1().min_w_0().ml(px(3.)).overflow_hidden().whitespace_nowrap().child(group.label.clone()))@@ -1031,7 +1033,7 @@ impl Workbench {let editor_command = resource.command.clone().filter(|command| matches!(command["id"].as_str(), Some("_workbench.open" | "_workbench.diff")));div().id(id.clone())- .group(id.clone())+ .debug_selector(|| id.to_string()).h(px(ROW_HEIGHT))// The icon 4px past the indent, measured against the reference with ui-pair..pl(px(INDENT * (2 + level + tree_depth.unwrap_or(0)) as f32 + 4.))@@ -1056,7 +1058,8 @@ impl Workbench {cx.notify();})).on_mouse_down(MouseButton::Right, cx.listener(move |workbench, event: &MouseDownEvent, window, cx| {- workbench.show_context_menu(MenuId::ScmResourceStateContext, &context, Bounds::new(event.position, Default::default()), args.clone(), window, cx);+ let actions = crate::menus::menu_group_actions(&workbench.menus, MenuId::ScmResourceStateContext, &context, |group| group != "inline");+ workbench.show_context_menu_actions(actions, &context, Bounds::new(event.position, Default::default()), args.clone(), window, cx);})).child(icon.mr(px(6.)))// scmViewPane.ts `fileDecorations: { colors: false }`: only the letter takes the decoration's color.diff --git a/port/ledger.md b/port/ledger.mdindex d552556f425..c52c8eab8dc 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -529,7 +529,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/contrib/remoteTunnel | workbench contribution | | removed | | no sign-in/AI by decision (port/notes.md); not ported || workbench/contrib/replNotebook | workbench contribution | M17 | verified | | verified (session m17d): cargo test -p app repl; ui-pair m17/interactive-restart.json with replPair.open repl (executed, restored, executed again, status bar) matches (/tmp/m17f); repl_notebook.rs: `$tryShowNotebookDocument` with view type `repl` (ReplEditorInput: one editor per notebook, `ensureInputBoxCell`, `REPL - N` label or `asRepl` label, scratchpad close without asking, soft revert on dispose, tab kind 4 `jupyter-notebook` editor `repl`, `debug-line-by-line` icon), the last cell as the input box under the list of the others (interactive.rs draws and runs both), `repl.execute` (insert before the input), `repl.input.focus`, `repl.focusLastItemExecuted`, `mostRecentReplEditor`, editors delta `viewType: repl`: cargo test -p app repl_notebook, ui-pair m17/interactive-window.json (replPair.open repl). The REPL editor comes back after a reload (ReplEditorSerializer `workbench.editorinputs.replEditorInput`, notebooks.rs). REPL hot exit (ReplWindowWorkingCopyEditorHandler: `notebook/<type>/repl` backups, a REPL editor opened on the restored notebook): cargo test -p app a_repl_backup_opens_a_repl_editor. Not done: the status bar while the REPL input has the focus (reference: `LF` only, then `Spaces: 4 LF Cell 1 of 1`; port: `Ln 1, Col 1 Spaces: 4 LF`), ui-pair m17/interactive-window.json (replPair.open repl) || workbench/contrib/sash | workbench contribution | M11 | verified | | `workbench.sash.size` (editor group sashes 4..20, their highlight 1..8; the part grid's sashes are its 4px gaps) and `workbench.sash.hoverDelay` on every sash (part grid, view panes, editor groups, find widget, keybindings table), three-dot grippers on the part sashes with `workbench.sash.autoHideGrippers` and its delay (part_grid.rs); cargo test -p app part_grid; verified: ui-pair hot-exit.json `sash` vs the reference (port/results/windows.md, milestone 11 verification) |-| workbench/contrib/scm | workbench contribution | M14 | ported | [3 S] workbench/scm_view.rs resource and resource group rows, scm_actions.rs repository row: their right-click menus keep the `inline` group, upstream drops it (scmViewPane.ts `onListContextMenu`, util.ts `collectContextMenuActions`)<br>[3 S] workbench/scm_tree.rs tree rows: the `src` folder's twistie and label sit at x 66 and 104 against the reference's 80 and 100, without its indent guides, folder decoration dot and path hover (ui-pair m11/scm-folder-menu.json `tree`, `hover`) | Resource folder menu with its resources as arguments, inline on hover (cargo test -p app a_folder_row a_folder_collects; ui-pair m11/scm-folder-menu.json `menu` with the git extension); SCM view: input box, action button, groups, resources with decorations, inline and title actions, activity badge, status bar commands (workbench/scm_view.rs); same-named repositories told apart by labels.ts `shorten` of their parent folders (quick_input.rs `shorten` with labels.test.ts's posix cases): cargo test -p app shorten_cuts same_named_repositories; quick diff gutter and peek (quick_diff.rs, quick_diff_widget.rs), multiple repositories, tree view mode and sort (scm_tree.rs), Graph view (scm_history.rs, scm_graph_view.rs) with its history item ref picker and filters (scm_graph_view/ref_picker.rs; ui-pair m11/scm-graph-refs.json), view actions (scm_actions.rs), editor commands run from the resource row: cargo test -p app scm; Graph subjects draw their `$(icon)`s (cargo test -p app a_subject_draws_its_icons); Repositories view with selection modes, sort keys, nested repositories and explorer mode's artifact groups, folders and artifacts with their menus (scm_repositories_view.rs; cargo test -p app the_repositories_ explorer_mode_), its Shift+click range and list keys (cargo test -p app the_repositories_tree_takes_shift_clicks_and_keys), Escape and `list.toggleSelection` (cargo test -p app escape_and_toggle_selection_leave_the_shown_repositories), the lone repository's expansion and `scm.repositoriesViewState` (cargo test -p app lone_repository), the shown repositories and sort key across sessions (cargo test -p app the_shown_repositories_come_back_with_their_sort_key), inline submenus with their contributed icon (cargo test -p app an_inline_submenu_opens_with_the_toolbar_arguments extension_submenus), the Repositories rows' inset, indent guides and "..." (cargo test -p app the_repositories_rows_draw_inset_guides_and_more_actions) |+| workbench/contrib/scm | workbench contribution | M14 | ported | [3 S] workbench/scm_tree.rs tree rows: the `src` folder's twistie and label sit at x 66 and 104 against the reference's 80 and 100, without its indent guides, folder decoration dot and path hover (ui-pair m11/scm-folder-menu.json `tree`, `hover`) | Resource folder menu with its resources as arguments, inline on hover (cargo test -p app a_folder_row a_folder_collects; ui-pair m11/scm-folder-menu.json `menu` with the git extension); SCM view: input box, action button, groups, resources with decorations, inline and title actions, activity badge, status bar commands (workbench/scm_view.rs); same-named repositories told apart by labels.ts `shorten` of their parent folders (quick_input.rs `shorten` with labels.test.ts's posix cases): cargo test -p app shorten_cuts same_named_repositories; quick diff gutter and peek (quick_diff.rs, quick_diff_widget.rs), multiple repositories, tree view mode and sort (scm_tree.rs), Graph view (scm_history.rs, scm_graph_view.rs) with its history item ref picker and filters (scm_graph_view/ref_picker.rs; ui-pair m11/scm-graph-refs.json), view actions (scm_actions.rs), editor commands run from the resource row: cargo test -p app scm; Graph subjects draw their `$(icon)`s (cargo test -p app a_subject_draws_its_icons); Repositories view with selection modes, sort keys, nested repositories and explorer mode's artifact groups, folders and artifacts with their menus (scm_repositories_view.rs; cargo test -p app the_repositories_ explorer_mode_), its Shift+click range and list keys (cargo test -p app the_repositories_tree_takes_shift_clicks_and_keys), Escape and `list.toggleSelection` (cargo test -p app escape_and_toggle_selection_leave_the_shown_repositories), the lone repository's expansion and `scm.repositoriesViewState` (cargo test -p app lone_repository), the shown repositories and sort key across sessions (cargo test -p app the_shown_repositories_come_back_with_their_sort_key), inline submenus with their contributed icon (cargo test -p app an_inline_submenu_opens_with_the_toolbar_arguments extension_submenus), the Repositories rows' inset, indent guides and "..." (cargo test -p app the_repositories_rows_draw_inset_guides_and_more_actions) || workbench/contrib/screenshotTool | workbench contribution | | removed | | Artur: internal infrastructure or developer tool with no 1:1 counterpart in the native port || workbench/contrib/scrollLocking | workbench contribution | M14 | verified | | workbench/scroll_locking.rs: Toggle and Hold Locked Scrolling and the prominent `status.scrollLockingEnabled` entry: cargo test -p app scroll_locking; a locked wheel scroll moves every other visible editor as far from its position when tracked (`onDidEditorPaneScroll`; cargo test -p app a_locked_scroll_moves_every_other_visible_editor); Hold locks while its key is down and unlocks on the key up (keybindingService.ts `enableKeybindingHoldMode`; cargo test -p app a_held_key_locks_scrolling_until_it_goes_up); without a focused element Hold toggles, as the key up reaches the workbench through the focus path || workbench/contrib/search | workbench contribution | M12 | verified | | Search view (workbench/search_view.rs, search_actions.rs) and its model (search_model.rs): cargo test -p app search_model (searchResult, fileMatch and replace tests) and workbench::search_actions (context menu, input history, hover right click, the replace preview opened and updated with the replace string), port/tools/ui-pair frames match the reference in dark, light and hc (port/notes.md milestone 12); anythingQuickAccess.ts file picks: cargo test -p app anything_quick_access quick_open. No notebook or AI results; Find in Folder from the Explorer (cargo test -p app find_in_folder; ui-pair m12/find-in-folder.json with `search.mode` newEditor matches); ui-pair m12/search-replace.json (query, Replace input, preview) matches; the message words at their exact widths, so "2 results in 2 files - Open in editor" fits one line as in the reference (cargo test -p app the_message_words_take_their_exact_width; pair: same box, 408 device px wide) |