Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(hover): keep a plain text hover that fits on one line

rokarturaae2fd4d32c9
diff --git a/README.md b/README.md
index f42a362d36e..06d228e8c71 100644
--- a/README.md
+++ b/README.md
@@ -11,15 +11,15 @@ Coverage of VS Code 1.147.0, from [port/ledger.md](port/ledger.md) (584 rows). V
```mermaid
pie showData
- "verified" : 413
- "ported" : 17
+ "verified" : 414
+ "ported" : 16
"removed" : 126
"n/a" : 28
```
| area | verified | ported | removed | n/a | verified of in scope |
|---|---:|---:|---:|---:|---|
-| src/vs/platform | 68 | 1 | 30 | 13 | `████████████████████ 99%` |
+| src/vs/platform | 69 | 0 | 30 | 13 | `████████████████████ 100%` |
| workbench contribution | 62 | 6 | 30 | 3 | `██████████████████░░ 91%` |
| built-in extension | 88 | 1 | 6 | 0 | `████████████████████ 99%` |
| MainThread* shape (Rust side) | 59 | 0 | 30 | 0 | `████████████████████ 100%` |
@@ -31,7 +31,7 @@ pie showData
| src/vs/editor | 1 | 1 | 1 | 1 | `██████████░░░░░░░░░░ 50%` |
| src/vs/base | 0 | 0 | 2 | 3 | `████████████████████ 100%` |
| port feature | 1 | 0 | 0 | 0 | `████████████████████ 100%` |
-| **all** | **413** | **17** | **126** | **28** | `███████████████████░ 96%` |
+| **all** | **414** | **16** | **126** | **28** | `███████████████████░ 96%` |
<!-- coverage:end -->
`removed` are parts left out by decision: AI features, Microsoft services, telemetry, remote and tunnels ([port/notes.md](port/notes.md)). `n/a` are upstream test infrastructure and the Electron process, IPC and DOM layers the native architecture replaces.
diff --git a/native/crates/app/src/workbench/hover.rs b/native/crates/app/src/workbench/hover.rs
index cd0ce14f294..9908be3f29f 100644
--- a/native/crates/app/src/workbench/hover.rs
+++ b/native/crates/app/src/workbench/hover.rs
@@ -582,7 +582,9 @@ impl Workbench {
let mut content_height = LINE_HEIGHT;
// `.markdown-hover > .hover-contents`: max-width 500px, word-wrap.
let wraps = !is_markdown && !preview && language_status.is_none();
- if wraps && content_width > TEXT_MAX_WIDTH {
+ // Only text past the max width wraps: one that fits keeps its line in a box of its rounded width.
+ let overflows = wraps && content_width > TEXT_MAX_WIDTH;
+ if overflows {
content_width = TEXT_MAX_WIDTH;
content_height = wrapped_lines(&hover.text, window) as f32 * LINE_HEIGHT;
}
@@ -645,7 +647,7 @@ impl Workbench {
})
.when_some(language_status.map(|(_, rows)| rows), |panel, rows| panel.child(rows))
.when_some(markdown, |panel, markdown| panel.child(self.hover_markdown(markdown, hover, cx)))
- .when(wraps, |panel| panel.child(div().whitespace_normal().child(hover.text.clone())))
+ .when(wraps, |panel| panel.child(div().debug_selector(|| "workbench-hover-text".into()).when(overflows, |text| text.whitespace_normal()).child(hover.text.clone())))
.when(policy, |panel| panel.child(self.policy_status_bar(cx)))
.when(preview, |panel| panel.child(
div()
diff --git a/native/crates/app/src/workbench/hover/tests.rs b/native/crates/app/src/workbench/hover/tests.rs
index 457974948eb..3dd709b1b9d 100644
--- a/native/crates/app/src/workbench/hover/tests.rs
+++ b/native/crates/app/src/workbench/hover/tests.rs
@@ -455,6 +455,26 @@ fn a_markdown_hover_wraps_at_the_max_width_and_is_placed_by_its_measured_size(cx
assert_eq!(links, ["command:extension.js-debug.createDiagnostics"]);
}
+/// hoverWidget.css `.monaco-hover`: a plain text hover is as wide as its text, which stays on one line (a resolving
+/// tree item's "Loading..." drew its last dot on a second line below the box).
+#[gpui::test]
+fn a_plain_text_hover_that_fits_keeps_its_text_on_one_line(cx: &mut TestAppContext) {
+ let (workbench, cx) = open_workbench("hover-plain-text", cx);
+ let target = Bounds { origin: point(px(300.), px(400.)), size: size(px(16.), px(22.)) };
+ for extra_padding_x in [0., 0.37, 0.5, 1.11, 6.] {
+ for text in ["Loading...", "Explorer", "Run and Debug (⇧⌘D)", "Extensions (⇧⌘X)"] {
+ let options = HoverOptions { extra_padding_x, ..HoverOptions::element() };
+ workbench.update_in(cx, |workbench, window, cx| workbench.show_managed_hover("target", super::HoverContent::Text(text.into()), options, target, window, cx));
+ cx.update(|window, cx| {
+ window.simulate_next_frame(cx);
+ drop(window.draw(cx));
+ });
+ let height = cx.debug_bounds("workbench-hover-text").expect("the text draws").size.height;
+ assert_eq!(height, px(super::LINE_HEIGHT), "{text:?} with {extra_padding_x}px more padding is one line");
+ }
+ }
+}
+
/// Each `<a>` is its own tab stop, also two adjacent links to one href, and a styled link stays one.
#[test]
fn adjacent_links_to_one_href_are_two_links() {
diff --git a/port/ledger.md b/port/ledger.md
index 92b6fe954de..ab45aae922d 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -218,7 +218,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| platform/globalKeybindings | src/vs/platform | M9 | verified | | system_wide_keybindings.rs GlobalShortcuts over Carbon RegisterEventHotKey (cargo test -p app system_wide: globalKeybindingsMainService.test.ts register, unregister on update, failed labels and retry, dedupe, trigger with and without args; Studio run: ctrl+alt+cmd+f19 with "systemWide": true opens the Command Palette while Finder stays frontmost, not with false); one window, so the multi-window routing and crashed-window tests do not apply; the process exit releases the hot keys (the shutdown case) |
| platform/gpu | src/vs/platform | | removed | | Artur: internal infrastructure or developer tool with no 1:1 counterpart in the native port |
| platform/history | src/vs/platform | M11 | verified | | contextScopedHistoryWidget.ts: `history.showPrevious`/`showNext` with `historyNavigationWidgetFocus` and the enablement keys on the find, replace, search, search editor and debug console inputs (cargo test -p app -- find_widget history); historyWidgetKeybindingHint.ts `showHistoryKeybindingHint` on the Search inputs' "(⇅ for history)" suffix (cargo test -p app -- history_hint: fails without it once Up is rebound); recently opened and File > Open Recent with Clear Recently Opened are platform/workspaces (cargo test -p app -- recently_opened menubar, port/results/open-recent.md) |
-| platform/hover | src/vs/platform | M9 | ported | [3 S] hover.rs:648: a plain text hover laid out at its measured width can wrap its last character: a resolving tree item's "Loading..." draws "Loading.." with the last dot on a second line below the box, where the reference fits it on one line (ui-pair port/fixtures/extensions/ui-tree-checkbox.json step hover-loading) | workbench/hover.rs: cargo test -p app hover (reference hover boxes; hoverService.test.ts pointer centering both ways, side re-evaluation right, left and above, capped-height fallbacks, tall side hover, empty content, pending hover cancelled by a click and by leaving, Alt lock and release; delay, instant, leave, click and key hide); `showAndFocusLastHover` focuses the hover's container and Escape there hides it (cargo test -p app the_accessible_view_reads_a_workbench_hover); `workbench.action.showHover` (`_showAndFocusHoverForActiveElement`) shows the focused item's hover focused: a managed hover (`ActionViewItem`) with `trapFocus`, Tab and Shift+Tab looping over the container and its markdown links (hoverWidget.ts `addFocusTrap`; Enter opens the focused link) and `lastFocusedElementBeforeOpen` focused again on Escape, a delayed hover (settingsWidgets.ts rows) without (cargo test -p app show_hover_focuses show_hover_on_a_focused_list a_folder_in_the_installation tab_loops_over_a_trap_focus_hovers_links); its targets are the items that take the focus in the port: the accessible view's toolbar, the timeline title toolbar, the banner's close button, the settings list rows and the status bar entry focused with statusbarActions.ts `workbench.statusBar.focusNext`/`focusPrevious`/`focusFirst`/`focusLast`/`clearFocus` (the focused entry's hover is the target the last frame painted inside it, workbench/hover.rs `painted_hover_within`; cargo test -p app the_status_bar_keys_move_an_entry_focus_with_its_hover); the activity bar's and its global bar's items, focused with actionbar.ts keys (workbench/action_bar.rs: Up/Down loop, Home/End, Enter and Space press, the hover painted inside the focused item; cargo test -p app the_activity_bar_items_take_the_keyboard_focus_with_their_hover); the panel and secondary side bar titles' three action bars (tabs, the merged view's actions, the global actions; Left/Right, Tab and Shift+Tab between them, Shift+Tab from the content, Tab on to it) and the panel tabs' hover with their open command's keybinding (compositeBarActions.ts `computeTitle`; cargo test -p app the_panel_title_bars_take_the_keyboard_focus_with_their_hover); pane header and merged view title actions, the tab stop between the header or title and the body (cargo test -p app the_pane_header_actions_are_a_tab_stop_with_their_hover a_merged_view_title_is_the_tab_stop_before_its_body); `persistence.sticky` (updateTitleBarEntry.ts' tooltip): locked, no key listener, Alt and other targets' hovers leave it, a press outside hides it (cargo test -p app a_sticky_hover_stays_until_a_press_outside_it); HTML content (languageStatus.ts `_combinedEntryTooltip`, updateTooltip.ts) does not hide on hover (cargo test -p app the_pointer_moves_onto_the_combined_entrys_html_hover); nested hovers (hoverService.ts `_hoverStack`, `MAX_HOVER_NESTING_DEPTH`) have no caller: no hover content in the port holds a workbench hover target (languageStatus.ts links and pin button and updateTooltip.ts' buttons take `nativeHoverDelegate` or `title`); markdown hovers (`IMarkdownString` with its `isTrusted`) render through `markdownRenderer` (workbench/markdown_view.rs `markdown_blocks`: bold, code, lists, headings, codicons, rules, untrusted `command:` links dropped to text) at most 500px wide, measured by a hidden first frame before `layout` places them, with the Tab-focused link outlined in `focusBorder` on each row it wraps to (cargo test -p app a_markdown_hover_wraps_at_the_max_width_and_is_placed_by_its_measured_size a_markdown_rule_collapses_its_margins tab_loops_over_a_trap_focus_hovers_links); screenshot pairs vs ref-hover dumps (port/results/hover.md); a panel tab's hover with its badge description (`computeTitle` appends `badge.getDescription()`: markers "Total {0} Problems", comments "{0} Unresolved Comments"; cargo test -p app a_panel_tab_hover_appends_the_badge_description); the side bar title's Views and More Actions... button of a container with several panes, the tab stop before the first pane header, Enter and Space open its Views submenu (cargo test -p app the_side_bar_title_more_actions_is_the_tab_stop_before_the_first_pane_header); the active editor tab (multiEditorTabsControl.ts, the group's only tab with `tabIndex = 0`): Shift+Tab from the editor in tab focus mode, Tab back, Left/Up and Right/Down open the neighbor without wrapping and Home/End the ends with `focusTabControl`, Enter and Space open the editor with the focus, a press leaves the focus where it is, its hover per group (cargo test -p app the_active_editor_tab_takes_the_keyboard_focus_with_its_hover); the update title bar entry (updateTitleBarEntry.ts, `MenuId.TitleBarUpdate`'s toolbar of its own): a tab stop with Shift+Tab from the activity bar and Tab back, Enter and Space run its action, `workbench.action.showHover` shows its sticky tooltip with the focus on its buttons (`focusTooltip`; cargo test -p app show_hover_on_the_update_title_bar_entry_focuses_its_tooltip); Shift+F10 on the focused tab shows its context menu below the tab (cargo test -p app the_active_editor_tab_takes_the_keyboard_focus_with_its_hover); the tabs' close actions (each tab's `ActionBar`, one tab stop per tab, inactive tabs too) and the group's editor actions toolbar (one tab stop, Left/Right/Home/End inside) in the DOM order between the active tab and the editor, Enter on a close action closes its tab (workbench/editor_status.rs `group_title_tab_stops`; cargo test -p app the_tab_close_actions_and_the_editor_actions_toolbar_are_tab_stops the_active_editor_tab_takes_the_keyboard_focus_with_its_hover); the main window's title bar toolbars in titlebarPart.ts' DOM order before the activity bar: the command center (`MenuId.CommandCenter` with the navigation buttons), the update entry and the action toolbar (editor actions, layout controls, the bell after them as `MenuId.TitleBar`'s trailing group, Manage, `...`), each one tab stop whose items run their command on Enter and Space (cargo test -p app the_title_bar_toolbars_are_tab_stops_in_the_dom_order show_hover_on_the_update_title_bar_entry_focuses_its_tooltip); F6 in an editor window focuses that window's status bar (ui-pair port/fixtures/ui-pair/editor-window-f6.json on the host lane: the port and the reference both outline the editor window's status bar); an editor window's title bar toolbars (compact mode, always on top, its editor actions) as tab stops of their own, Tab from them on to the editor part's active tab, Shift+Tab back, Enter running the item (cargo test -p app an_editor_windows_title_bar_toolbars_are_its_own_tab_stops) |
+| platform/hover | src/vs/platform | M9 | verified | | workbench/hover.rs: a plain text hover that fits keeps its one line (cargo test -p app a_plain_text_hover_that_fits_keeps_its_text_on_one_line; ui-pair ui-tree-checkbox.json hover-loading shows "Loading..." on one line); cargo test -p app hover (reference hover boxes; hoverService.test.ts pointer centering both ways, side re-evaluation right, left and above, capped-height fallbacks, tall side hover, empty content, pending hover cancelled by a click and by leaving, Alt lock and release; delay, instant, leave, click and key hide); `showAndFocusLastHover` focuses the hover's container and Escape there hides it (cargo test -p app the_accessible_view_reads_a_workbench_hover); `workbench.action.showHover` (`_showAndFocusHoverForActiveElement`) shows the focused item's hover focused: a managed hover (`ActionViewItem`) with `trapFocus`, Tab and Shift+Tab looping over the container and its markdown links (hoverWidget.ts `addFocusTrap`; Enter opens the focused link) and `lastFocusedElementBeforeOpen` focused again on Escape, a delayed hover (settingsWidgets.ts rows) without (cargo test -p app show_hover_focuses show_hover_on_a_focused_list a_folder_in_the_installation tab_loops_over_a_trap_focus_hovers_links); its targets are the items that take the focus in the port: the accessible view's toolbar, the timeline title toolbar, the banner's close button, the settings list rows and the status bar entry focused with statusbarActions.ts `workbench.statusBar.focusNext`/`focusPrevious`/`focusFirst`/`focusLast`/`clearFocus` (the focused entry's hover is the target the last frame painted inside it, workbench/hover.rs `painted_hover_within`; cargo test -p app the_status_bar_keys_move_an_entry_focus_with_its_hover); the activity bar's and its global bar's items, focused with actionbar.ts keys (workbench/action_bar.rs: Up/Down loop, Home/End, Enter and Space press, the hover painted inside the focused item; cargo test -p app the_activity_bar_items_take_the_keyboard_focus_with_their_hover); the panel and secondary side bar titles' three action bars (tabs, the merged view's actions, the global actions; Left/Right, Tab and Shift+Tab between them, Shift+Tab from the content, Tab on to it) and the panel tabs' hover with their open command's keybinding (compositeBarActions.ts `computeTitle`; cargo test -p app the_panel_title_bars_take_the_keyboard_focus_with_their_hover); pane header and merged view title actions, the tab stop between the header or title and the body (cargo test -p app the_pane_header_actions_are_a_tab_stop_with_their_hover a_merged_view_title_is_the_tab_stop_before_its_body); `persistence.sticky` (updateTitleBarEntry.ts' tooltip): locked, no key listener, Alt and other targets' hovers leave it, a press outside hides it (cargo test -p app a_sticky_hover_stays_until_a_press_outside_it); HTML content (languageStatus.ts `_combinedEntryTooltip`, updateTooltip.ts) does not hide on hover (cargo test -p app the_pointer_moves_onto_the_combined_entrys_html_hover); nested hovers (hoverService.ts `_hoverStack`, `MAX_HOVER_NESTING_DEPTH`) have no caller: no hover content in the port holds a workbench hover target (languageStatus.ts links and pin button and updateTooltip.ts' buttons take `nativeHoverDelegate` or `title`); markdown hovers (`IMarkdownString` with its `isTrusted`) render through `markdownRenderer` (workbench/markdown_view.rs `markdown_blocks`: bold, code, lists, headings, codicons, rules, untrusted `command:` links dropped to text) at most 500px wide, measured by a hidden first frame before `layout` places them, with the Tab-focused link outlined in `focusBorder` on each row it wraps to (cargo test -p app a_markdown_hover_wraps_at_the_max_width_and_is_placed_by_its_measured_size a_markdown_rule_collapses_its_margins tab_loops_over_a_trap_focus_hovers_links); screenshot pairs vs ref-hover dumps (port/results/hover.md); a panel tab's hover with its badge description (`computeTitle` appends `badge.getDescription()`: markers "Total {0} Problems", comments "{0} Unresolved Comments"; cargo test -p app a_panel_tab_hover_appends_the_badge_description); the side bar title's Views and More Actions... button of a container with several panes, the tab stop before the first pane header, Enter and Space open its Views submenu (cargo test -p app the_side_bar_title_more_actions_is_the_tab_stop_before_the_first_pane_header); the active editor tab (multiEditorTabsControl.ts, the group's only tab with `tabIndex = 0`): Shift+Tab from the editor in tab focus mode, Tab back, Left/Up and Right/Down open the neighbor without wrapping and Home/End the ends with `focusTabControl`, Enter and Space open the editor with the focus, a press leaves the focus where it is, its hover per group (cargo test -p app the_active_editor_tab_takes_the_keyboard_focus_with_its_hover); the update title bar entry (updateTitleBarEntry.ts, `MenuId.TitleBarUpdate`'s toolbar of its own): a tab stop with Shift+Tab from the activity bar and Tab back, Enter and Space run its action, `workbench.action.showHover` shows its sticky tooltip with the focus on its buttons (`focusTooltip`; cargo test -p app show_hover_on_the_update_title_bar_entry_focuses_its_tooltip); Shift+F10 on the focused tab shows its context menu below the tab (cargo test -p app the_active_editor_tab_takes_the_keyboard_focus_with_its_hover); the tabs' close actions (each tab's `ActionBar`, one tab stop per tab, inactive tabs too) and the group's editor actions toolbar (one tab stop, Left/Right/Home/End inside) in the DOM order between the active tab and the editor, Enter on a close action closes its tab (workbench/editor_status.rs `group_title_tab_stops`; cargo test -p app the_tab_close_actions_and_the_editor_actions_toolbar_are_tab_stops the_active_editor_tab_takes_the_keyboard_focus_with_its_hover); the main window's title bar toolbars in titlebarPart.ts' DOM order before the activity bar: the command center (`MenuId.CommandCenter` with the navigation buttons), the update entry and the action toolbar (editor actions, layout controls, the bell after them as `MenuId.TitleBar`'s trailing group, Manage, `...`), each one tab stop whose items run their command on Enter and Space (cargo test -p app the_title_bar_toolbars_are_tab_stops_in_the_dom_order show_hover_on_the_update_title_bar_entry_focuses_its_tooltip); F6 in an editor window focuses that window's status bar (ui-pair port/fixtures/ui-pair/editor-window-f6.json on the host lane: the port and the reference both outline the editor window's status bar); an editor window's title bar toolbars (compact mode, always on top, its editor actions) as tab stops of their own, Tab from them on to the editor part's active tab, Shift+Tab back, Enter running the item (cargo test -p app an_editor_windows_title_bar_toolbars_are_its_own_tab_stops) |
| platform/imageResize | src/vs/platform | | removed | | no AI or Microsoft services by decision (port/notes.md); API stays inert |
| platform/instantiation | src/vs/platform | | removed | | Artur: internal infrastructure or developer tool with no 1:1 counterpart in the native port |
| platform/ipc | src/vs/platform | | n/a | | Electron process, IPC or DOM layer; replaced by the single-process Rust/GPUI architecture (port/notes.md) |