Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(scm): inline actions on hovered Changes rows, rows inset with rounded corners

rokartur98cffe75312c
diff --git a/native/crates/app/src/workbench/scm_actions/tests.rs b/native/crates/app/src/workbench/scm_actions/tests.rs
index 33ca8dd2021..5ce7b32f859 100644
--- a/native/crates/app/src/workbench/scm_actions/tests.rs
+++ b/native/crates/app/src/workbench/scm_actions/tests.rs
@@ -299,8 +299,8 @@ fn a_folder_row_shows_the_resource_folder_menu_with_its_resources(cx: &mut TestA
});
}
-/// abstractTree.ts indent guides in the Changes view: the group's children draw its guide 16px in from the rows'
-/// 4px modernUI inset.
+/// abstractTree.ts indent guides in the Changes view: the group's children draw its guide 16px in from the group
+/// row, which modernUI padding.css insets with every row.
#[gpui::test]
fn the_changes_tree_draws_indent_guides(cx: &mut TestAppContext) {
let (workbench, _receiver, cx) = workbench_in("scm-folder-guides", cx);
@@ -317,7 +317,9 @@ fn the_changes_tree_draws_indent_guides(cx: &mut TestAppContext) {
cx.run_until_parked();
let group = cx.debug_bounds("scm-group-0-2").expect("the view shows the group");
let guide = cx.debug_bounds("tree-guide").expect("the group's children draw its guide");
- assert_eq!(f32::from(guide.origin.x - group.origin.x), 4. + 16.);
+ assert_eq!(f32::from(guide.origin.x - group.origin.x), 16.);
+ let pane = cx.debug_bounds("scm-list").expect("the view draws its list");
+ assert_eq!(f32::from(group.origin.x - pane.origin.x), 4.);
}
/// scmViewPane.ts `onListContextMenu` and util.ts `collectContextMenuActions`: a repository, resource group or
@@ -357,6 +359,42 @@ fn row_context_menus_leave_out_the_inline_group(cx: &mut TestAppContext) {
}
}
+/// scmViewPane.ts `ResourceRenderer` and `ResourceGroupRenderer`: a hovered row shows its `inline` actions, which run
+/// on click.
+#[gpui::test]
+fn a_hovered_row_shows_its_inline_actions(cx: &mut TestAppContext) {
+ use crate::menus::{Entry, MenuItem};
+ let (workbench, _receiver, cx) = workbench_in("scm-row-inline", cx);
+ let ran = std::rc::Rc::new(std::cell::RefCell::new(Vec::new()));
+ cx.simulate_resize(gpui::size(gpui::px(1024.), gpui::px(768.)));
+ request(&workbench, cx, "$registerSourceControl", register(0, "/w/repo"));
+ 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, id) in [(MenuId::ScmResourceGroupContext, "git.stageAll"), (MenuId::ScmResourceStateContext, "git.stage")] {
+ workbench.menus.push(MenuItem { menu, entry: Entry::Command { id: id.into(), precondition: None, toggled: None, alt: None }, title: id.into(), group: "inline".into(), order: 0., when: None });
+ let ran = ran.clone();
+ workbench.commands.register(id, move |_, _, _, _| {
+ ran.borrow_mut().push(id);
+ crate::commands::Outcome::done()
+ });
+ }
+ 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, command, right) in [("scm-group-0-2", "git.stageAll", 8. + 18. + 4. + 11.), ("scm-resource-0-2-1", "git.stage", 8. + 11.)] {
+ let bounds = cx.debug_bounds(row).unwrap_or_else(|| panic!("the view shows {row}"));
+ // The 22px button's center: past the row's 8px padding and, on the group row, its count badge.
+ let button = gpui::point(bounds.right() - gpui::px(right), bounds.center().y);
+ cx.simulate_mouse_move(button, None, gpui::Modifiers::none());
+ cx.run_until_parked();
+ cx.simulate_click(button, gpui::Modifiers::none());
+ cx.run_until_parked();
+ assert_eq!(ran.borrow_mut().pop(), Some(command), "{row}: the hovered row's inline action runs on click");
+ }
+}
+
/// 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_tree.rs b/native/crates/app/src/workbench/scm_tree.rs
index a0b648696ec..9f23500f1d9 100644
--- a/native/crates/app/src/workbench/scm_tree.rs
+++ b/native/crates/app/src/workbench/scm_tree.rs
@@ -79,10 +79,11 @@ impl Workbench {
.h(px(ROW_HEIGHT))
.relative()
// A group's children: one tree level (8px) further in than the group row's twistie.
- .pl(px(INDENT * (2 + depth) as f32 + 7.))
- .pr(px(12.))
+ .pl(px(INDENT * (2 + depth) as f32 + 3.))
+ .pr(px(8.))
.flex()
.items_center()
+ .rounded(px(4.))
.cursor_pointer()
.hover(|row| row.bg(self.color("list.hoverBackground")))
.on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {
diff --git a/native/crates/app/src/workbench/scm_view.rs b/native/crates/app/src/workbench/scm_view.rs
index d78fbab3c9d..90829bdb801 100644
--- a/native/crates/app/src/workbench/scm_view.rs
+++ b/native/crates/app/src/workbench/scm_view.rs
@@ -655,14 +655,14 @@ impl Workbench {
}
self.push_scm_repository_children(&mut rows, provider, providers.len(), usize::from(show_repositories), window, cx);
}
- // abstractTree.ts indent guides, from the rows' 4px modernUI inset.
let depths = rows.iter().map(|row| row.depth).collect();
let active: Vec<usize> = rows.iter().enumerate().filter(|(_, row)| row.selected).map(|(index, _)| index).collect();
let group = gpui::SharedString::from("scm-list");
let guides = self.tree_guides_in_group(group.clone(), depths, &active);
let inset = self.pane_row_inset();
- let rows = rows.into_iter().enumerate().map(|(index, row)| div().relative().child(row.element).children(guides.row(index, inset)));
- div().id("scm-list").group(group).flex_1().min_h_0().overflow_y_scroll().track_focus(&self.scm.list_focus).children(rows).into_any_element()
+ // modernUI padding.css: the rows sit `pane_row_inset` in from the pane's edges, the guides from the row.
+ let rows = rows.into_iter().enumerate().map(|(index, row)| div().relative().mx(px(inset)).child(row.element).children(guides.row(index, 0.)));
+ div().id("scm-list").debug_selector(|| "scm-list".into()).group(group).flex_1().min_h_0().overflow_y_scroll().track_focus(&self.scm.list_focus).children(rows).into_any_element()
}
};
ViewPane { id: SCM_CHANGES_VIEW, title: "Changes".into(), description: None, actions: Some(actions.into_any_element()), draws_more: true, show_actions, body }
@@ -715,9 +715,10 @@ impl Workbench {
.id(gpui::SharedString::from(format!("scm-repository-{handle}")))
.debug_selector(move || format!("scm-repository-{handle}"))
.h(px(ROW_HEIGHT))
- .pr(px(12.))
+ .pr(px(8.))
.flex()
.items_center()
+ .rounded(px(4.))
.cursor_pointer()
.when(selected, |row| row.bg(self.color("list.inactiveSelectionBackground")))
.hover(|row| row.bg(self.color("list.hoverBackground")))
@@ -916,8 +917,8 @@ impl Workbench {
let handle = provider.handle;
div()
.id(gpui::SharedString::from(format!("scm-input-{handle}")))
- .pl(px(INDENT * (1 + level) as f32 + TWISTIE))
- .pr(px(12.))
+ .pl(px(INDENT * (1 + level) as f32 + TWISTIE - 4.))
+ .pr(px(8.))
.pt(px(4.))
.pb(px(4.))
.when(!editing, |row| {
@@ -969,8 +970,8 @@ impl Workbench {
.flex_none()
.flex()
.items_center()
- .pl(px(INDENT * (1 + level) as f32 + TWISTIE))
- .pr(px(12.))
+ .pl(px(INDENT * (1 + level) as f32 + TWISTIE - 4.))
+ .pr(px(8.))
.child(div().flex_1().h(px(26.)).flex().rounded(px(2.)).bg(background).text_color(foreground).when(!enabled, |button| button.opacity(0.4)).child(main).children(dropdown))
}
@@ -1000,13 +1001,15 @@ impl Workbench {
div()
.id(id.clone())
.debug_selector(|| id.to_string())
+ .group(id.clone())
.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.
- .pl(px(INDENT * (1 + level) as f32 + 7.))
- .pr(px(12.))
+ .pl(px(INDENT * (1 + level) as f32 + 3.))
+ .pr(px(8.))
.flex()
.items_center()
+ .rounded(px(4.))
.cursor_pointer()
.when(selected, |row| row.bg(self.color("list.inactiveSelectionBackground")))
.hover(|row| row.bg(self.color("list.hoverBackground")))
@@ -1054,12 +1057,14 @@ impl Workbench {
div()
.id(id.clone())
.debug_selector(|| id.to_string())
+ .group(id.clone())
.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.))
- .pr(px(12.))
+ // The icon at the indent, measured against the reference with ui-pair.
+ .pl(px(INDENT * (2 + level + tree_depth.unwrap_or(0)) as f32))
+ .pr(px(8.))
.flex()
.items_center()
+ .rounded(px(4.))
.cursor_pointer()
.when(resource.faded, |row| row.opacity(0.7))
.when(selected, |row| row.bg(self.color("list.inactiveSelectionBackground")))
diff --git a/port/ledger.md b/port/ledger.md
index 1930fa2b51c..9402be20344 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 `scm_resource_row`: a hovered resource row shows no inline actions with the git extension (reference: Open File, Discard Changes, Stage Changes; the folder row above shows its own)<br>[3 S] workbench/scm_view.rs Changes view rows: hover and selection backgrounds span the pane, square; the reference's sit 4px in with rounded corners (modernUI padding.css, as the Repositories view's rows) | Tree mode folder rows a level in from their group, label after the twistie without folder icons, decoration dot and path hover, indent guides over the Changes rows (cargo test -p app the_changes_tree_draws_indent_guides; ui-pair m11/scm-folder-menu.json on a git copy of the fixture workspace with `scm.defaultViewMode` tree `hover`: matches the reference); row context menus without their inline group (cargo test -p app row_context_menus_leave_out_the_inline_group); 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_view.rs `scm_resource_row`: a hovered resource row shows no hover, the reference's `<path> • Modified` after its delay (ui-pair Ctrl+Shift+G, hover on a resource row of a git folder with changes)<br>[3 S] workbench/scm_view.rs Changes rows: the group's count badge sits 4px and the resource's decoration letter 2px left of the reference's (same ui-pair) | Inline actions on hovered group and resource rows, rows inset `pane_row_inset` with rounded corners (cargo test -p app a_hovered_row_shows_its_inline_actions the_changes_tree_draws_indent_guides; ui-pair hover on a git folder with changes: matches the reference); Tree mode folder rows a level in from their group, label after the twistie without folder icons, decoration dot and path hover, indent guides over the Changes rows (cargo test -p app the_changes_tree_draws_indent_guides; ui-pair m11/scm-folder-menu.json on a git copy of the fixture workspace with `scm.defaultViewMode` tree `hover`: matches the reference); row context menus without their inline group (cargo test -p app row_context_menus_leave_out_the_inline_group); 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) |