Visual Studio Code, rebuilt in Rust
Rust
fix(scm): inset Repositories rows, draw indent guides and the row's ...
rokarture3677707763a
diff --git a/native/crates/app/src/workbench/scm_repositories_view.rs b/native/crates/app/src/workbench/scm_repositories_view.rsindex e1942644279..727b52b6dda 100644--- a/native/crates/app/src/workbench/scm_repositories_view.rs+++ b/native/crates/app/src/workbench/scm_repositories_view.rs@@ -9,7 +9,7 @@ use gpui::{App, Bounds, ClickEvent, Context, Div, FocusHandle, Modifiers, MouseBuse serde_json::json;use super::Workbench;-use super::scm_view::{INDENT, ROW_HEIGHT, TWISTIE};+use super::scm_view::{ROW_HEIGHT, TWISTIE};use super::view_panes::{PaneContainer, SCM_REPOSITORIES_VIEW, ViewPane};use crate::commands::Outcome;use crate::menus::MenuId;@@ -245,14 +245,26 @@ impl Workbench {let more = self.more_actions_button("scm-repositories-title-more", SCM_REPOSITORIES_VIEW, MenuId::ScmSourceControlTitle, context, Vec::new(), foreground, cx);let actions = div().flex().items_center().gap(px(2.)).child(inline).child(self.action_bar_item(SCM_REPOSITORIES_VIEW, "more", more, cx));let focused = self.scm.repositories.focus.is_focused(window);+ let tree = self.scm_repository_tree();+ let depths = tree.iter().map(|row| match row {+ RepositoryRow::Repository { depth, .. } | RepositoryRow::ArtifactFolder { depth, .. } | RepositoryRow::Artifact { depth, .. } => depth + 1,+ RepositoryRow::ArtifactGroup { .. } => 2,+ });+ let focus = self.scm_tree_focus();+ let active: Vec<usize> = tree.iter().enumerate().filter(|(_, row)| self.scm_tree_row_selected(&row.id()) || focus.as_deref() == Some(&row.id())).map(|(index, _)| index).collect();+ let group = SharedString::from("scm-repositories");+ let guides = self.tree_guides_in_group(group.clone(), depths.collect(), &active);+ let inset = self.pane_row_inset();let mut rows = Vec::new();- for row in self.scm_repository_tree() {- rows.push(match row {- RepositoryRow::Repository { provider, depth, expandable } => self.scm_repositories_row(provider, depth, expandable, focused, window, cx).into_any_element(),- row => self.scm_artifact_row(row, focused, window, cx).into_any_element(),- });+ for (index, row) in tree.into_iter().enumerate() {+ let row = match row {+ RepositoryRow::Repository { provider, depth, expandable } => self.scm_repositories_row(provider, depth, expandable, focused, window, cx),+ row => self.scm_artifact_row(row, focused, window, cx),+ };+ // modernUI padding.css: the rows sit `pane_row_inset` in from the pane's edges, the guides from the row.+ rows.push(div().relative().mx(px(inset)).child(row).children(guides.row(index, 0.)));}- let body = div().id("scm-repositories").flex_1().min_h_0().overflow_y_scroll().track_scroll(&self.scm.repositories.scroll).track_focus(&self.scm.repositories.focus).children(rows).into_any_element();+ let body = div().id("scm-repositories").debug_selector(|| "scm-repositories".into()).group(group).flex_1().min_h_0().overflow_y_scroll().track_scroll(&self.scm.repositories.scroll).track_focus(&self.scm.repositories.focus).children(rows).into_any_element();ViewPane { id: SCM_REPOSITORIES_VIEW, title: "Repositories".into(), description: None, actions: Some(actions.into_any_element()), draws_more: true, show_actions: focused, body }}@@ -413,7 +425,7 @@ impl Workbench {.relative().h(px(ROW_HEIGHT))// abstractTree.ts: `DefaultIndent` (8) + (depth - 1) * indent, its depth counting from 1.- .pl(px((depth + 1) as f32 * INDENT))+ .pl(px(8. + depth as f32 * self.tree_indent())).pr(px(12.)).flex().items_center()@@ -511,7 +523,7 @@ impl Workbench {.relative().h(px(ROW_HEIGHT))// abstractTree.ts: `DefaultIndent` (8) + (depth - 1) * indent, its depth counting from 1.- .pl(px((depth + 1) as f32 * INDENT))+ .pl(px(8. + depth as f32 * self.tree_indent())).pr(px(12.)).flex().items_center()diff --git a/native/crates/app/src/workbench/scm_view.rs b/native/crates/app/src/workbench/scm_view.rsindex a7acf56c587..5efe3628e63 100644--- a/native/crates/app/src/workbench/scm_view.rs+++ b/native/crates/app/src/workbench/scm_view.rs@@ -777,6 +777,25 @@ impl Workbench {}let context = self.scm_context(provider, None, None, window);toolbar = toolbar.child(self.inline_actions(menu, None, &context, vec![Self::provider_arg(provider)], foreground, cx));+ // `connectPrimaryMenu`: the actions outside the primary group are the toolbar's "...".+ let primary = if menu == MenuId::ScmTitle { "navigation" } else { "inline" };+ let secondary = crate::menus::menu_group_actions(&self.menus, menu, &context, |group| group != primary);+ if !secondary.is_empty() {+ let more = self.icon("toolbar-more", 22., 16., foreground);+ let args = vec![Self::provider_arg(provider)];+ let more = more.id(gpui::SharedString::from(format!("scm-repository-more-{menu:?}-{handle}"))).debug_selector(move || format!("scm-repository-more-{menu:?}-{handle}"));+ toolbar = toolbar.child(+ more.rounded(px(4.))+ .cursor_pointer()+ .hover(|icon| icon.bg(self.color("toolbar.hoverBackground")))+ .on_mouse_down(MouseButton::Left, cx.listener(move |workbench, event: &MouseDownEvent, window, cx| {+ window.prevent_default();+ cx.stop_propagation();+ workbench.show_context_menu_actions(secondary.clone(), &context, Bounds::new(event.position, Default::default()), args.clone(), window, cx);+ }))+ .child(self.hover_target(gpui::SharedString::from(format!("scm-repository-more-hover-{menu:?}-{handle}")), HoverContent::Text("More Actions...".into()), HoverOptions::action_item())),+ );+ }let count = provider.count();let show_count = match self.setting("scm.providerCountBadge").as_str() {Some("visible") => true,diff --git a/native/crates/app/src/workbench/scm_view/tests.rs b/native/crates/app/src/workbench/scm_view/tests.rsindex efd09371f25..634604e5fc5 100644--- a/native/crates/app/src/workbench/scm_view/tests.rs+++ b/native/crates/app/src/workbench/scm_view/tests.rs@@ -160,6 +160,42 @@ fn the_repositories_view_shows_on_focus_with_nested_repositories(cx: &mut TestAp});}+/// abstractTree.ts and modernUI padding.css: the Repositories rows sit 4px in from the pane, a selected nested+/// repository's parent draws its indent guide, and scmRepositoryRenderer.ts `connectPrimaryMenu` puts the menu's+/// actions outside `inline` behind the row's "...".+#[gpui::test]+fn the_repositories_rows_draw_inset_guides_and_more_actions(cx: &mut TestAppContext) {+ use crate::menus::{Entry, MenuAction, MenuId, MenuItem};+ let (workbench, _receiver, cx) = workbench_in("scm-repositories-guides", cx);+ cx.simulate_resize(gpui::size(gpui::px(1024.), gpui::px(768.)));+ workbench.update_in(cx, |workbench, window, cx| {+ let mut child = register(1, "/w/zeta/sub", false);+ child[1] = json!(0);+ for args in [register(0, "/w/zeta", false), child] {+ drop(workbench.handle_scm_request("$registerSourceControl", &args, window, cx));+ }+ let entry = Entry::Command { id: "git.fetch".into(), precondition: None, toggled: None, alt: None };+ workbench.menus.push(MenuItem { menu: MenuId::ScmSourceControlInline, entry, title: "Fetch".into(), group: "1_more".into(), order: 0., when: None });+ drop(workbench.execute_command("workbench.view.scm", vec![], window, cx));+ workbench.set_part_hidden(crate::workbench::layout::Part::SideBar, false, cx);+ drop(workbench.execute_command("workbench.scm.repositories.focus", vec![], window, cx));+ workbench.click_scm_tree_row("repo:1", Default::default());+ });+ cx.run_until_parked();+ let body = cx.debug_bounds("scm-repositories").expect("the Repositories view draws");+ let guide = cx.debug_bounds("tree-guide").expect("the selected child's parent draws its guide");+ assert_eq!(f32::from(guide.origin.x - body.origin.x), 4. + 16.);+ let more = cx.debug_bounds("scm-repository-more-ScmSourceControlInline-1").expect("the row draws its \"...\"");+ assert_eq!(f32::from(body.origin.x + body.size.width - (more.origin.x + more.size.width)), 4. + 12.);+ cx.simulate_mouse_down(more.center(), gpui::MouseButton::Left, gpui::Modifiers::none());+ cx.run_until_parked();+ workbench.read_with(cx, |workbench, _| {+ let menu = workbench.context_menu.as_ref().expect("the \"...\" opens");+ assert!(matches!(&menu.levels[0].actions[..], [MenuAction::Command { id, .. }] if id == "git.fetch"), "{:?}", menu.levels[0].actions);+ assert_eq!(menu.args, [json!({ "$mid": 5, "handle": 1 })]);+ });+}+/// scmViewService.ts: a click selects one repository, Cmd+click adds one in `multiple` mode, `single` mode keeps the/// first shown, and `toggleRepositoryVisibility` in `single` mode swaps the shown repository.#[gpui::test]diff --git a/port/ledger.md b/port/ledger.mdindex aa1bea6fc07..28aa6850828 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] scm_repositories_view.rs:415: the Repositories rows lack the reference's 4px pane inset, the tree's indent guides and the repository row's `...` for its menu's secondary actions <br> [3 M] scm_view.rs:114, :742: headers as view_panes panes; labels.ts shorten | SCM view: input box, action button, groups, resources with decorations, inline and title actions, activity badge, status bar commands (workbench/scm_view.rs); 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) |+| workbench/contrib/scm | workbench contribution | M14 | ported | [3 M] scm_view.rs:114, :742: headers as view_panes panes; labels.ts shorten | SCM view: input box, action button, groups, resources with decorations, inline and title actions, activity badge, status bar commands (workbench/scm_view.rs); 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) |