Visual Studio Code, rebuilt in Rust
Rust
fix(editor): keep scrollbars shown over the minimap and the track
rokarturdea4dbe55a19
diff --git a/native/crates/app/src/workbench/editor_menus/tests.rs b/native/crates/app/src/workbench/editor_menus/tests.rsindex 3b8d94698ba..e1b6616ae92 100644--- a/native/crates/app/src/workbench/editor_menus/tests.rs+++ b/native/crates/app/src/workbench/editor_menus/tests.rs@@ -547,3 +547,32 @@ fn the_scrollbar_menu_writes_the_minimap_settings(cx: &mut TestAppContext) {cx.simulate_keystrokes("escape");std::fs::remove_dir_all(dir).unwrap();}++/// editorScrollbar.ts `listenOnDomNode: viewDomNode`: the minimap and the scrollbar track are the editor too, the+/// scrollbars stay shown over them and hide once the pointer leaves the editor.+#[gpui::test]+fn the_scrollbars_stay_shown_over_the_minimap_and_the_track(cx: &mut TestAppContext) {+ let (dir, workbench, cx) = workbench_with("scrollbars-minimap", &["a.txt"], cx);+ workbench.update(cx, |workbench, _| {+ let text: String = (1..=300).map(|line| format!("line {line}\n")).collect();+ let edit = (Position::new(0, 0), Position::new(1, 11), text, false);+ workbench.editors.active_mut().unwrap().execute_edits(vec![edit], None, crate::editor::EditReason::Unknown("test"));+ });+ cx.run_until_parked();+ workbench.update(cx, |_, cx| cx.notify());+ cx.run_until_parked();+ let (bounds, minimap_width) = workbench.read_with(cx, |workbench, _| (workbench.text_area_bounds.get(), workbench.minimap.info.as_ref().unwrap().0.width as f32));+ let y = px(bounds.top() + 100.);+ let shown = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.scrollbars.shown);+ cx.simulate_mouse_move(point(px(bounds.left() + 100.), y), None, gpui::Modifiers::none());+ assert!(shown(cx), "over the text");+ cx.simulate_mouse_move(point(px(bounds.right() - crate::editor::VERTICAL_SCROLLBAR_WIDTH - minimap_width / 2.), y), None, gpui::Modifiers::none());+ assert!(shown(cx), "over the minimap");+ cx.simulate_mouse_move(point(px(bounds.right() - 5.), y), None, gpui::Modifiers::none());+ assert!(shown(cx), "over the vertical scrollbar");+ cx.executor().advance_clock(std::time::Duration::from_secs(1));+ assert!(shown(cx), "no timeout hides them while the pointer is over the editor");+ cx.simulate_mouse_move(point(px(bounds.left() - 20.), y), None, gpui::Modifiers::none());+ assert!(!shown(cx), "leaving the editor hides them");+ std::fs::remove_dir_all(dir).unwrap();+}diff --git a/native/crates/app/src/workbench/editor_view.rs b/native/crates/app/src/workbench/editor_view.rsindex 74673d8a275..59a142fcb0c 100644--- a/native/crates/app/src/workbench/editor_view.rs+++ b/native/crates/app/src/workbench/editor_view.rs@@ -1363,19 +1363,15 @@ impl Workbench {workbench.inlay_hints_modifiers_changed(event.modifiers, cx);})).on_hover(cx.listener(|workbench, hovered: &bool, window, cx| {- workbench.scrollbars.mouse_over = *hovered;- match hovered {- true => workbench.reveal_scrollbars(cx),- false => {- workbench.hide_scrollbars(cx);- workbench.debug_hover_mouse_left(window.mouse_position(), window, cx);- workbench.content_hover_mouse_left(window.mouse_position(), window, cx);- workbench.definition_link_mouse_left();- workbench.commenting_hover_moved(None, cx);- workbench.coverage_mouse_moved(false, None, cx);- }+ if !*hovered {+ workbench.debug_hover_mouse_left(window.mouse_position(), window, cx);+ workbench.content_hover_mouse_left(window.mouse_position(), window, cx);+ workbench.definition_link_mouse_left();+ workbench.commenting_hover_moved(None, cx);+ workbench.coverage_mouse_moved(false, None, cx);}}))+ .child(self.scrollbars_mouse_over_listener((group, model_id), cx).absolute().inset_0())// The line's row sets `row_target` first: moves bubble from the row up to the text area..on_mouse_move(cx.listener(|workbench, event: &MouseMoveEvent, window, cx| {let row_target = workbench.content_hover.row_target.take();@@ -1776,6 +1772,46 @@ impl Workbench {}}+ /// editorScrollbar.ts `listenOnDomNode: viewDomNode`: mouseover and mouseleave of the whole editor, minimap, sticky+ /// scroll and scrollbars included; their hitboxes block the text area's `on_hover`.+ fn scrollbars_mouse_over_listener(&self, editor: (u32, u32), cx: &mut Context<Self>) -> gpui::Canvas<()> {+ let workbench = cx.entity();+ canvas(+ |_, _, _| {},+ move |bounds, _, window, _| {+ let moved = workbench.clone();+ window.on_mouse_event(move |event: &MouseMoveEvent, phase, _, cx| {+ if phase == DispatchPhase::Bubble {+ moved.update(cx, |workbench, cx| workbench.set_scrollbars_mouse_over(editor, bounds.contains(&event.position), cx));+ }+ });+ window.on_mouse_event(move |_: &gpui::MouseExitEvent, phase, _, cx| {+ if phase == DispatchPhase::Bubble {+ workbench.update(cx, |workbench, cx| workbench.set_scrollbars_mouse_over(editor, false, cx));+ }+ });+ },+ )+ }++ /// One state for every code editor: a leave counts only for the editor the pointer was over.+ fn set_scrollbars_mouse_over(&mut self, editor: (u32, u32), over: bool, cx: &mut Context<Self>) {+ match (over, self.scrollbars.pointer_editor) {+ (true, Some(current)) if current == editor => {}+ (true, _) => {+ self.scrollbars.pointer_editor = Some(editor);+ self.scrollbars.mouse_over = true;+ self.reveal_scrollbars(cx);+ }+ (false, Some(current)) if current == editor => {+ self.scrollbars.pointer_editor = None;+ self.scrollbars.mouse_over = false;+ self.hide_scrollbars(cx);+ }+ (false, _) => {}+ }+ }+/// The sliders over the overview ruler and along the bottom (scrollbars.css, abstractScrollbar.ts): a press/// on a track centers the slider on the pointer, then the slider follows the pointer until release.fn scrollbars_canvas(&self, editor: &OpenEditor, metrics: EditorMetrics, cx: &mut Context<Self>) -> gpui::Canvas<Vec<(Hitbox, Bounds<Pixels>, Axis)>> {@@ -3424,6 +3460,8 @@ impl RulerLanes {#[derive(Default)]pub(super) struct Scrollbars {pub mouse_over: bool,+ /// The code editor under the pointer, by group and model id; lists leave it empty.+ pointer_editor: Option<(u32, u32)>,pub(super) shown: bool,/// When `shown` last flipped, and the opacity the transition started from.changed: Option<(Instant, f32)>,diff --git a/port/fixtures/ui-pair/m8/scrollbar-hover.json b/port/fixtures/ui-pair/m8/scrollbar-hover.jsonnew file mode 100644index 00000000000..62ebc1e6750--- /dev/null+++ b/port/fixtures/ui-pair/m8/scrollbar-hover.json@@ -0,0 +1,12 @@+[+ { "wait": 4000 },+ { "hover": [500, 400] },+ { "wait": 600 },+ { "shot": "editor-hover" },+ { "hover": [950, 400] },+ { "wait": 1500 },+ { "shot": "minimap-hover" },+ { "hover": [1016, 400] },+ { "wait": 1500 },+ { "shot": "track-hover" }+]diff --git a/port/ledger.md b/port/ledger.mdindex 358c08514bc..a76e278b2ea 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -381,7 +381,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| platform/windows | src/vs/platform | M11 | verified | | windows_state.rs: cargo test -p app windows_state; ui-pair hot-exit.json `restored` (port/results/windows.md, milestone 11 verification). The default size stays 1024x768, the capture size of port/tools/ref-screenshot, where upstream takes 1200x800 or 1440x900 || platform/workspace | src/vs/platform | M12 | verified | | virtual workspaces (non-file folders): milestone 25; config/src/workspace.rs: folders, getFolder, toWorkspaceFolders, workspace label; cargo test -p config workspace (workspace.test.ts cases); api-workspace 4/4; verified: api-tests MOCHA_GREP="vscode API - (workspace|file system|env|types|tasks)" at 44a309311e1: every workspace, workspace-fs, workspace events, workspace-watcher and file system test passes, api-workspace 4/0/0 (port/results/api-tests.md "M12 verification"), api-workspace 4/4 || platform/workspaces | src/vs/platform | M12 | verified | | session.rs, recently_opened.rs, config/src/workspace.rs, workbench/workspace_editing.rs: cargo test -p exthost (workspaces.test.ts stable id case); cargo test -p config workspace:: 5/5; cargo test -p app recently_opened workspace_editing; ui-pair port/fixtures/ui-pair/m12/workspace-folders.json (Remove Folder from Workspace enters Untitled (Workspace)) |-| editor/browser | src/vs/editor | M8 | verified | | editor/view.rs, editor/folding.rs, editor/minimap.rs, editor/word_wrap.rs, editor/smooth_scroll.rs, editor/mouse_selection.rs, workbench/editor_view.rs, workbench/gutter_mouse.rs, workbench/editor_view/text_decorations.rs: cargo test -p app editor::view::tests editor::folding minimap section_headers editor_menus selection_corners whitespace control_characters gutter_presses word_wrap smooth_scroll diff_editor diff_gutter switch_side bracket_pair_guide wrapping_indent_repeats without_a_wrapping_indent file_compare char_ranges a_click_without_a_move mouse_selection text_clicks_select a_selecting_drag_below a_drag_into_the_vertical the_bottom_edge_hit a_drag_below_a_comment text_input:: outline_and_border_follow_the_css_cascade a_decoration_outline_is_drawn_outside_its_range decoration_types_set_and_remove_editor_decorations wrapping_a_padded_inlay_hint_skips_its_padding_box a_selection_over_changes_shows_the_selection_toolbar; ui-pair m12/compare.json, port/fixtures/ui-pair/menus/diff-gutter-selection.json, port/fixtures/ui-pair/m8/inlay-hint-wrap.json (port/notes.md milestones 8 and 14) |+| editor/browser | src/vs/editor | M8 | verified | | editor/view.rs, editor/folding.rs, editor/minimap.rs, editor/word_wrap.rs, editor/smooth_scroll.rs, editor/mouse_selection.rs, workbench/editor_view.rs, workbench/gutter_mouse.rs, workbench/editor_view/text_decorations.rs: cargo test -p app editor::view::tests editor::folding minimap section_headers editor_menus selection_corners whitespace control_characters gutter_presses word_wrap smooth_scroll diff_editor diff_gutter switch_side bracket_pair_guide wrapping_indent_repeats without_a_wrapping_indent file_compare char_ranges a_click_without_a_move mouse_selection text_clicks_select a_selecting_drag_below a_drag_into_the_vertical the_bottom_edge_hit a_drag_below_a_comment text_input:: outline_and_border_follow_the_css_cascade a_decoration_outline_is_drawn_outside_its_range decoration_types_set_and_remove_editor_decorations wrapping_a_padded_inlay_hint_skips_its_padding_box a_selection_over_changes_shows_the_selection_toolbar the_scrollbars_stay_shown_over_the_minimap_and_the_track; ui-pair m12/compare.json, port/fixtures/ui-pair/m8/scrollbar-hover.json (FOLDER=<reference>/src/vs/base/common FILE=strings.ts: the 14px scrollbar column matches with 0 px over 6% fuzz while the pointer is on the minimap and on the track), port/fixtures/ui-pair/menus/diff-gutter-selection.json, port/fixtures/ui-pair/m8/inlay-hint-wrap.json (port/notes.md milestones 8 and 14) || editor/common | src/vs/editor | M8 | verified | | app/src/editor, decorations.rs, link_computer.rs, syntax.rs, brackets/tree.rs, the diff crate: cargo test -p app editor:: decorations:: link_computer syntax:: auto_closing brackets lines_in_view_past_the_tokenized_ones the_word_at_a_column full_width_chars_take moving_down_keeps a_hyphen_next_to_a_class_escape_is_literal (13 ignored: upstream's `test.skip` cases); cargo test -p diff; typing on the 52k-line TS file under 16 ms per edit with the section headers and unicode highlights, trim and comment on it just opened under 16 ms, its bracket selection scan under 30 ms (port/notes.md "Scheduling differences"): cargo gc test --release -p app -- --ignored typing_latency_on_a_large_file. By design: the piece tree text buffer is a vector of lines (large files through workbench/large_file.rs) || editor/standalone | src/vs/editor | | removed | | Artur: internal infrastructure or developer tool with no 1:1 counterpart in the native port || editor/test | src/vs/editor | M6 | n/a | | upstream test infrastructure; the port tests with cargo test and port/tools |