Visual Studio Code, rebuilt in Rust
Rust
perf(outline): draw only the Outline rows in view
rokartur58c004ece0dd
diff --git a/README.md b/README.mdindex 1e59ccd13a1..cba77bf345c 100644--- a/README.md+++ b/README.md@@ -11,8 +11,8 @@ Coverage of VS Code 1.147.0, from [port/ledger.md](port/ledger.md) (584 rows). V```mermaidpie showData- "verified" : 407- "ported" : 23+ "verified" : 408+ "ported" : 22"removed" : 126"n/a" : 28```@@ -23,7 +23,7 @@ pie showData| workbench contribution | 59 | 9 | 30 | 3 | `█████████████████░░░ 87%` || built-in extension | 88 | 1 | 6 | 0 | `████████████████████ 99%` || MainThread* shape (Rust side) | 59 | 0 | 30 | 0 | `████████████████████ 100%` |-| workbench service | 58 | 7 | 23 | 7 | `██████████████████░░ 89%` |+| workbench service | 59 | 6 | 23 | 7 | `██████████████████░░ 91%` || src/vs/editor/contrib | 52 | 2 | 2 | 1 | `███████████████████░ 96%` || workbench part | 10 | 1 | 2 | 0 | `██████████████████░░ 91%` || extension host seam | 7 | 0 | 0 | 0 | `████████████████████ 100%` |@@ -31,7 +31,7 @@ pie showData| src/vs/editor | 0 | 2 | 1 | 1 | `░░░░░░░░░░░░░░░░░░░░ 0%` || src/vs/base | 0 | 0 | 2 | 3 | `████████████████████ 100%` || port feature | 1 | 0 | 0 | 0 | `████████████████████ 100%` |-| **all** | **407** | **23** | **126** | **28** | `███████████████████░ 95%` |+| **all** | **408** | **22** | **126** | **28** | `███████████████████░ 95%` |<!-- 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/outline_pane.rs b/native/crates/app/src/workbench/outline_pane.rsindex 1cd5f05f9fe..c1f93ae2c66 100644--- a/native/crates/app/src/workbench/outline_pane.rs+++ b/native/crates/app/src/workbench/outline_pane.rs@@ -172,11 +172,15 @@ impl Workbench {let group = gpui::SharedString::from("outline-tree");let guides = self.tree_guides_in_group(group.clone(), rows.iter().map(|row| row.depth).collect(), &active);let inset = self.pane_row_inset();- let elements: Vec<AnyElement> = rows- .iter()- .enumerate()- .map(|(index, row)| div().relative().flex_none().child(self.outline_row(model_id, row, index, focused, focused_row == Some(row.id), query.as_ref(), cx)).children(guides.row(index, inset)).into_any_element())- .collect();+ // listView.ts renders only the rows in view; the window's height bounds the view before its first paint.+ let list_scroll = self.outline_list_scroll(rows.len());+ let first = ((list_scroll.scroll_top.max(0.) / ROW_HEIGHT) as usize).min(rows.len());+ let end = (first + (f32::from(window.viewport_size().height) / ROW_HEIGHT).ceil() as usize + 1).min(rows.len());+ let mut elements = vec![div().h(px(ROW_HEIGHT * first as f32)).flex_none().into_any_element()];+ for (index, row) in rows.iter().enumerate().take(end).skip(first) {+ elements.push(div().relative().flex_none().child(self.outline_row(model_id, row, index, focused, focused_row == Some(row.id), query.as_ref(), cx)).children(guides.row(index, inset)).into_any_element());+ }+ elements.push(div().h(px(ROW_HEIGHT * (rows.len() - end) as f32)).flex_none().into_any_element());let list = super::list_scroll::ListId::Outline;let sticky = if self.outline_pane.find.is_open() { Vec::new() } else { self.tree_sticky_rows(list, &rows.iter().map(|row| row.depth).collect::<Vec<_>>()) };let sticky_elements = sticky.iter().map(|sticky_row| self.outline_row(model_id, &rows[sticky_row.index], sticky_row.index, focused, focused_row == Some(rows[sticky_row.index].id), query.as_ref(), cx)).collect();@@ -223,8 +227,11 @@ impl Workbench {/// The rows the tree shows: the groups of several providers, then each element below its expanded parent,/// siblings in the Sort By order (`OutlineTreeSorter`).pub(super) fn outline_rows<'a>(&self, model_id: u32, outline: &'a OutlineModel) -> Vec<Row<'a>> {- let expanded = |id: &str| self.outline_row_expanded(model_id, id);- let shown_kind = |element: &OutlineElement| self.shows_symbol_kind("outline", element.symbol.kind);+ // Read each setting once: a lookup per symbol made the rows of a large outline cost a frame.+ let collapsed_by_default = self.setting("outline.collapseItems") == "alwaysCollapse";+ let expanded = |id: &str| collapsed_by_default == self.outline_pane.toggled.contains(&(model_id, id.to_string()));+ let shown_kinds: Vec<bool> = (0..SHOW_KIND.len() as u64).map(|kind| self.shows_symbol_kind("outline", kind)).collect();+ let shown_kind = |element: &OutlineElement| shown_kinds.get(element.symbol.kind as usize).copied().unwrap_or(true);let filter = self.outline_query().filter(|query| query.filter_mode);let shown = |element: &OutlineElement| shown_kind(element) && filter.as_ref().is_none_or(|query| query.keeps(element, &shown_kind));let sort_by = self.outline_pane.view_state.sort_by;diff --git a/native/crates/app/src/workbench/outline_pane/tests.rs b/native/crates/app/src/workbench/outline_pane/tests.rsindex f1de671304f..a609bc00c10 100644--- a/native/crates/app/src/workbench/outline_pane/tests.rs+++ b/native/crates/app/src/workbench/outline_pane/tests.rs@@ -249,6 +249,34 @@ fn the_keys_move_the_focus_and_the_list_commands_act_on_it(cx: &mut TestAppConteassert_eq!(state(cx), (None, Vec::new()));}+/// listView.ts renders only the rows in view: a long outline draws the first rows, and the last ones once revealed,+/// in their place below the rows above them.+#[gpui::test]+fn the_outline_draws_only_the_rows_in_view(cx: &mut TestAppContext) {+ let source: String = (0..2000).map(|line| format!("const s{line} = 1;\n")).collect();+ let (workbench, cx, receiver, _) = open(cx, "outline-virtual", &source);+ workbench.update(cx, |workbench, cx| {+ workbench.language_features.register(crate::workbench::document_symbols::REGISTER, vec![json!(11), json!("*"), json!("Test")]);+ workbench.language_providers_changed(crate::workbench::document_symbols::REGISTER, cx);+ });+ let range = |line: usize| json!({ "startLineNumber": line, "startColumn": 1, "endLineNumber": line, "endColumn": 20 });+ let symbols: Vec<_> = (0..2000).map(|index| json!({ "name": format!("s{index}"), "detail": "", "kind": 13, "range": range(index + 1), "selectionRange": range(index + 1), "children": [] })).collect();+ answer(&receiver, "$provideDocumentSymbols", json!(symbols), cx);+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("outline.focus", Vec::new(), window, cx)));+ cx.run_until_parked();+ assert!(cx.debug_bounds("outline-row-0").is_some());+ assert!(cx.debug_bounds("outline-row-1999").is_none(), "a row far below the view is not drawn");++ workbench.update_in(cx, |workbench, window, cx| {+ workbench.outline_key_down("end", window, cx);+ });+ cx.run_until_parked();+ let list = workbench.read_with(cx, |workbench, _| workbench.outline_pane.scroll.bounds());+ let last = cx.debug_bounds("outline-row-1999").expect("the revealed row is drawn");+ assert!(cx.debug_bounds("outline-row-0").is_none(), "a row scrolled out of view is not drawn");+ assert_eq!(last.bottom(), list.bottom(), "the last row ends the scrolled list");+}+/// breadcrumbsWidget.css: a symbol item is its icon, 3px, its label at the label's exact width and the 16px separator.#[gpui::test]fn the_breadcrumb_separator_follows_the_label_s_exact_width(cx: &mut TestAppContext) {diff --git a/port/ledger.md b/port/ledger.mdindex 8364cb281c6..da8d1615a26 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -417,7 +417,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/services/model | workbench service | M8 | verified | | `_schemaShouldMaintainUndoRedoElements` with modelService's disposed-model cache: a reopened unchanged file gets its undo stack back with its version ids, 20 MB cap, `files.restoreUndoStack`; `_computeEdits` for revert (editor/model_service.rs): cargo test -p app model_service, 19 modelService.test.ts cases; 'setValue should clear undo stack' tests `TextModel.setValue`, which no port caller needs (a whole-text replacement is an undoable edit); `_schemaShouldMaintainUndoRedoElements` with modelService's disposed-model cache: a reopened unchanged file gets its undo stack back, 20 MB cap, `files.restoreUndoStack` (editor/model_service.rs): cargo test -p app model_service || workbench/services/notebook | workbench service | M17 | verified | | notebookDocumentService.ts cell URIs (`notebook::cell_uri`, `parse_cell_uri`): cargo test -p app notebook (base 7 handle, URL-safe scheme fragment, as upstream's generate/parse); api-tests notebook suites open cell documents by these URIs || workbench/services/notification | workbench service | M11 | verified | | `notify`, `prompt` and the Do Not Disturb filters (global and per source, stored in application storage) on Workbench (notifications_view.rs); cargo test -p app notifications_view; verified: ui-pair messages.json vs the reference (port/results/windows.md, milestone 11 verification) |-| workbench/services/outline | workbench service | M13 | ported | [3 M] outline_pane.rs:175: the Outline view builds an element for every symbol row on each frame, upstream's tree renders only the visible rows; with a 57k-line TS file open each frame takes 200-300 ms, about two thirds of it here | the document symbols outline of the active editor (workbench/outline_pane.rs): breadcrumb symbols from `getItemEnclosingPosition` with `breadcrumbs.symbolPath` and `breadcrumbs.show*`, the Outline view's tree; cargo test -p app outline_pane; ui-pair Outline title actions with a.ts symbols (port/results/language-features.md Outline title actions) |+| workbench/services/outline | workbench service | M13 | verified | | the document symbols outline of the active editor (workbench/outline_pane.rs): breadcrumb symbols from `getItemEnclosingPosition` with `breadcrumbs.symbolPath` and `breadcrumbs.show*`, the Outline view's tree, drawing only the rows in view as listView.ts does (cargo test -p app the_outline_draws_only_the_rows_in_view); cargo test -p app outline_pane; ui-pair Outline title actions with a.ts symbols (port/results/language-features.md Outline title actions) || workbench/services/output | workbench service | M15 | verified | | a logger's `group` is set only by the shared process (workbench/services/sharedProcess) and the hidden telemetry loggers (workbench/contrib/telemetry), `when` by no caller. output.rs: channels read from their files from a start offset, Replace/Clear move it, log channels from visible loggers, `OutputViewFilters` and `parseLogEntryAt` (output/filter.rs), the active channel and its log level: cargo test -p app output (14 tests) || workbench/services/panecomposite | workbench service | M11 | verified | | active side bar container (built-in or contributed, workbench/view_containers.rs) and active panel view (workbench.panelpart.activepanelid), open and close per location; panel view containers move between the panel and the secondary side bar by drag and drop (`moveViewContainerToLocation`, `views.customizations`; cargo test -p app a_panel_view_dropped_on_the_secondary_side_bar, ui-pair port/results/layout.md); no moving side bar containers or single views; ui-pair port/results/references-view.md and problems.md; active side bar view and active panel view (workbench.panelpart.activepanelid) only; no view container registry; verified: ui-pair port/results/references-view.md and problems.md (milestone 11 verification) || workbench/services/path | workbench service | M12 | verified | | the user home is $HOME (path_label, tildify), hasValidBasename is file_actions.rs is_valid_basename (cargo test -p app validates_file_names); pathService.test.ts covers only remote path semantics (no remote); verified at port-m12b-verify: cargo test -p app validates_file_names 1/1 |