Visual Studio Code, rebuilt in Rust
Rust
fix(editor): draw the editor part again when its size changes
rokartur63f6fabece80
diff --git a/native/crates/app/src/workbench/editor_groups.rs b/native/crates/app/src/workbench/editor_groups.rsindex e66b4905c1c..3e958f12313 100644--- a/native/crates/app/src/workbench/editor_groups.rs+++ b/native/crates/app/src/workbench/editor_groups.rs@@ -811,7 +811,21 @@ impl Workbench {// The centered layout's margins beside the groups (centeredViewLayout.ts), measured out of the groups' room.let margins = self.centered_margins();let (left, right) = margins.unwrap_or_default();- let measure = canvas(move |bounds, _, _| part_bounds.set(bounds.map(f32::from)), |_, _, _, _| ()).absolute().top_0().bottom_0().left(px(left)).right(px(right));+ // The grid and the watermark's shortcuts are laid out from the size measured on the frame before.+ let measure = canvas(+ move |bounds, window, cx| {+ let bounds = bounds.map(f32::from);+ if part_bounds.replace(bounds) != bounds {+ super::part_view::redraw_after_frame(window, cx);+ }+ },+ |_, _, _, _| (),+ )+ .absolute()+ .top_0()+ .bottom_0()+ .left(px(left))+ .right(px(right));let centered_chrome = self.centered_layout_chrome(margins, cx);// floatingPanels.css floats the main window's parts; an editor window's part fills it.let floating = self.editor_groups.part == MAIN_PART;diff --git a/port/notes.md b/port/notes.mdindex 15854fc9d0a..0db014d0a3a 100644--- a/port/notes.md+++ b/port/notes.md@@ -1122,6 +1122,11 @@ Work the port does at another time than 1.147.0, accepted with a measured same r- Baseline on `b867659888d` (`cargo gc test -p app`, the bin target): 3721 passed, 21 failed, 20 ignored. Layout and text snapping without the Chromium patches (16: tab, outline, quick open, search message, editor type picker and icon label widths; settings checkbox and row heights; welcome view wraps; debug toolbar, decoration outline and icon picker half pixels); rounded corners and blur (`corner_lab`); hover dropped on a key press (65696abd52a); a test's app not freed (836ad8f1b9e); Retained Mode (2: `webview_views` showing a view after a context key changed without a notify, the markdown hover's size; both pass with `GPUI_VIEW_RETENTION=0`, which leaves the other 19).- Retained Mode differential check (B2, `fast/retained.rs` `retained_frame_difference`, `check_settled_frames`): `GPUI_RETENTION_CHECK=1 cargo gc test -p app` draws each test's settled frame (no dirty window, effect or next-frame callback left) a second time with retention off and fails the test where the painted primitives or hitboxes differ; a test can call `Window::retained_frame_difference` itself. Only settled frames: a value measured during paint (a hover's size, a list's bounds) draws a stale frame that the next one heals by design. Options compared: (1) gpui-fast's own tests (`fast/tests/splice_late_layout.rs`, `cached_layout.rs`) run a scenario twice with `set_view_retention(true/false)` and compare what the test observes, which needs every view test written twice; (2) a per-window retention toggle in a test harness (oscarbc96/parla `crates/ui_testing/src/harness.rs`, MPL-2.0), again without a frame diff; (3) one check in the draw loop over the whole suite, the one taken, since it covers the 3700 existing view tests without touching them. Zed's GPUI has no Retained Mode and no such check.- Trap: `window.refresh()` inside paint is a no-op (`window.rs` `refresh` marks dirty only outside a draw), so a value measured in a canvas and read by the next render draws again through `part_view::redraw_after_frame` (`cx.notify` on the view after the frame), as `welcome_page.rs` does. Fixed so: markdown hover size (`hover.rs`), a list's scroll layer bounds (`list_scroll.rs`, `suggest_widget.rs`). A clock read in render uses `cx.background_executor().now()` so the test clock drives it (input caret, `input_box_view.rs`).+- Retention check, root causes (head 9e3ce24c9e2: 112 tests failed with `GPUI_RETENTION_CHECK=1`):+ - A view notified while a frame draws (`cx.notify` in a canvas's prepaint or paint, as `editor_view.rs` `editor_laid_out` notifies once the text area's width gives the minimap and viewport) lands in the invalidator's `dirty_views` without marking the window dirty (`WindowInvalidator::invalidate_view`, as zed and Wu do), so no frame follows and the window keeps the frame drawn before the size was known until an unrelated event draws: the editor without its minimap, the tab bar and the text area 79 to 120 px too wide. Fixed in `Window::draw` (6457e49f3c8): a frame that leaves notified views behind marks the window dirty, unless it requested an animation frame, which draws them anyway (in tests, which deliver no animation frames, a drag scrolling that notifies in paint would otherwise draw forever); the test draw loop in `App::flush_effects` draws such a window again before it returns. 88 of the 112, `retained_check.rs` `a_view_notified_while_drawing_draws_again`.+ - A false difference of the check: it ran at the start of the next `flush_effects`, after the test had changed state without a notify (`folder.reveal` in `explorer_actions` tests), which the full render showed and no mode would have drawn. It now runs as the flush that drew the frame ends, before the test runs on. 9, `retained_check.rs` `a_change_after_the_settled_frame_is_not_a_retention_difference`.+ - The explorer reads the disk as it draws (`explorer.rs` `entries`), and a file added or deleted on disk notified nothing, so the cached side bar kept the old rows until an unrelated workbench change; `files_changed` now notifies when a change is in a folder the tree shows, as `explorerService.ts` refreshes on `onDidChangeFiles`. Two test setups changed the disk under a shown explorer with no watcher running: `code_lens` tests shared one folder per process (now one per test thread), `local_history_actions` kept the user data, and so the history it writes, inside the workspace folder (now beside it). 6, `explorer_actions` `a_file_added_on_disk_draws_in_the_tree`.+ - The editor part's size, measured by a canvas (`editor_groups.rs` `editor_groups_part`) and read by the next render (the grid's layout, the watermark's shortcuts above 478 px), drew nothing when it changed, so the cached part kept the layout of the size before (a terminal or panel toggled, zen mode); it now draws again through `part_view::redraw_after_frame`. 7, the `terminal_view` tab and toolbar tests under `GPUI_RETENTION_CHECK=1`.- The 31 Wu commits (`git log -- native/vendor/wu`, newest first). Hunks: the commit's Rust and Metal hunks under `crates/`; failed: the hunks `patch --dry-run` rejects on the gpui-fast copy, each commit tried alone (a commit that builds on an earlier one also fails where that one is missing). Merge commits carry no change of their own.| Commit | Subject | Area | In gpui-fast | gpui-fast files | Hunks, failed |