Visual Studio Code, rebuilt in Rust
Rust
fix(scm): match the Repositories row padding and status labels to 1.147
rokartur452d8d1048cf
diff --git a/native/crates/app/src/workbench/scm_repositories_view.rs b/native/crates/app/src/workbench/scm_repositories_view.rsindex 727b52b6dda..79f616c1b00 100644--- a/native/crates/app/src/workbench/scm_repositories_view.rs+++ b/native/crates/app/src/workbench/scm_repositories_view.rs@@ -424,17 +424,19 @@ impl Workbench {.id(gpui::SharedString::from(format!("scm-repositories-row-{handle}"))).relative().h(px(ROW_HEIGHT))- // abstractTree.ts: `DefaultIndent` (8) + (depth - 1) * indent, its depth counting from 1.- .pl(px(8. + depth as f32 * self.tree_indent()))- .pr(px(12.))+ .rounded(px(4.))+ // abstractTree.ts: `DefaultIndent` (8) + (depth - 1) * indent, its depth counting from 1; the twistie's 6px+ // padding-right with its translateX(3px) puts the contents 3px after the chevron. modernUI padding.css: 4px right.+ .pl(px(11. + depth as f32 * self.tree_indent()))+ .pr(px(4.)).flex().items_center().cursor_pointer().text_color(foreground).when(selected, |row| row.bg(selection)).when(!selected, |row| row.hover(|row| row.bg(self.color("list.hoverBackground"))))- .children(outline.map(|outline| div().absolute().inset_0().border_1().border_color(outline)))- .child(twistie.id(("scm-repositories-twistie", handle)).on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {+ .children(outline.map(|outline| div().absolute().inset_0().rounded(px(4.)).border_1().border_color(outline)))+ .child(twistie.id(("scm-repositories-twistie", handle)).mr(px(3.)).on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {cx.stop_propagation();workbench.toggle_scm_tree_row(handle, None, repository_id(handle), cx);cx.notify();@@ -522,17 +524,19 @@ impl Workbench {.group(row_id.clone()).relative().h(px(ROW_HEIGHT))- // abstractTree.ts: `DefaultIndent` (8) + (depth - 1) * indent, its depth counting from 1.- .pl(px(8. + depth as f32 * self.tree_indent()))- .pr(px(12.))+ .rounded(px(4.))+ // abstractTree.ts: `DefaultIndent` (8) + (depth - 1) * indent, its depth counting from 1; the twistie's 6px+ // padding-right with its translateX(3px) puts the contents 3px after the chevron. modernUI padding.css: 4px right.+ .pl(px(11. + depth as f32 * self.tree_indent()))+ .pr(px(4.)).flex().items_center().cursor_pointer().text_color(foreground).when(selected, |row| row.bg(selection)).when(!selected, |row| row.hover(|row| row.bg(self.color("list.hoverBackground"))))- .children(outline.map(|outline| div().absolute().inset_0().border_1().border_color(outline)))- .child(twistie.id(SharedString::from(format!("scm-repositories-twistie-{id}"))).when(expandable, |twistie| {+ .children(outline.map(|outline| div().absolute().inset_0().rounded(px(4.)).border_1().border_color(outline)))+ .child(twistie.id(SharedString::from(format!("scm-repositories-twistie-{id}"))).mr(px(3.)).when(expandable, |twistie| {twistie.on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {cx.stop_propagation();workbench.toggle_scm_artifact_row(handle, toggle_group.clone(), toggle_id.clone(), cx);diff --git a/native/crates/app/src/workbench/scm_view.rs b/native/crates/app/src/workbench/scm_view.rsindex 08c46294513..84caf03dce1 100644--- a/native/crates/app/src/workbench/scm_view.rs+++ b/native/crates/app/src/workbench/scm_view.rs@@ -764,15 +764,36 @@ impl Workbench {let tooltip = command["tooltip"].as_str().map_or_else(|| label.clone(), str::to_string);let command = command.clone();let id = gpui::SharedString::from(format!("scm-repository-status-{menu:?}-{handle}-{index}"));+ // util.ts `StatusBarActionViewItem`: each text run is a span, a flex item, so its outer whitespace+ // collapses; scm.css gives it 2px margin-left.+ let span = |text: &str| Some(text.trim()).filter(|text| !text.is_empty()).map(|text| div().ml(px(2.)).child(text.to_string()).into_any_element());+ let chars: Vec<char> = label.chars().collect();+ let mut parts = Vec::new();+ let mut text = String::new();+ let mut at = 0;+ while at < chars.len() {+ if let Some((name, length)) = super::quick_input_view::icon_at(&chars[at..]) {+ parts.extend(span(&std::mem::take(&mut text)));+ parts.push(self.icon(&name, 16., 16., foreground).into_any_element());+ at += length;+ continue;+ }+ text.push(chars[at]);+ at += 1;+ }+ parts.extend(span(&text));toolbar = toolbar.child(div().id(id.clone()).ml(px(4.))- .px(px(3.))+ // modernUI: the action label's padding is 2px.+ .px(px(2.)).h(px(20.)).flex().items_center().rounded(px(4.))+ // actionbar.css `.action-label`: 11px.+ .text_size(px(11.)).whitespace_nowrap().cursor_pointer().hover(|action| action.bg(self.color("toolbar.hoverBackground")))@@ -780,7 +801,7 @@ impl Workbench {cx.stop_propagation();drop(workbench.run_dto_command(&command, window, cx));}))- .child(self.highlighted_label(&label, &[], foreground, 16., foreground))+ .children(parts).child(self.hover_target(id.clone(), HoverContent::Text(tooltip), HoverOptions::mouse())),);}diff --git a/native/crates/app/src/workbench/scm_view/tests.rs b/native/crates/app/src/workbench/scm_view/tests.rsindex 04e16073ca3..48f4ffa4385 100644--- a/native/crates/app/src/workbench/scm_view/tests.rs+++ b/native/crates/app/src/workbench/scm_view/tests.rs@@ -201,7 +201,7 @@ fn the_repositories_rows_draw_inset_guides_and_more_actions(cx: &mut TestAppContlet 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.);+ assert_eq!(f32::from(body.origin.x + body.size.width - (more.origin.x + more.size.width)), 4. + 4.);cx.simulate_mouse_down(more.center(), gpui::MouseButton::Left, gpui::Modifiers::none());cx.run_until_parked();workbench.read_with(cx, |workbench, _| {