Visual Studio Code, rebuilt in Rust
Rust
fix(notebook): fold levels, multi-range drag, sticky outline rows
rokarturc6da8d8aa06d
diff --git a/README.md b/README.mdindex 4cf08be9e06..cb5a31fedaf 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) (585 rows). V```mermaidpie showData- "verified" : 406- "ported" : 25+ "verified" : 407+ "ported" : 24"removed" : 126"n/a" : 28```@@ -20,7 +20,7 @@ pie showData| area | verified | ported | removed | n/a | verified of in scope ||---|---:|---:|---:|---:|---|| src/vs/platform | 68 | 1 | 30 | 13 | `████████████████████ 99%` |-| workbench contribution | 57 | 12 | 30 | 3 | `█████████████████░░░ 83%` |+| workbench contribution | 58 | 11 | 30 | 3 | `█████████████████░░░ 84%` || built-in extension | 88 | 1 | 6 | 0 | `████████████████████ 99%` || MainThread* shape (Rust side) | 59 | 0 | 30 | 0 | `████████████████████ 100%` || workbench service | 58 | 7 | 23 | 7 | `██████████████████░░ 89%` |@@ -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** | **406** | **25** | **126** | **28** | `███████████████████░ 94%` |+| **all** | **407** | **24** | **126** | **28** | `███████████████████░ 94%` |<!-- 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/notebook/outline.rs b/native/crates/app/src/notebook/outline.rsindex 34ba3398650..01c216052e7 100644--- a/native/crates/app/src/notebook/outline.rs+++ b/native/crates/app/src/notebook/outline.rs@@ -132,6 +132,37 @@ pub fn section_of(ranges: &[(usize, usize)], index: usize) -> Option<(usize, usiranges.iter().rev().find(|(start, end)| (*start..=*end).contains(&index)).copied()}+/// foldingController.ts `setFoldingStateUp` and `setFoldingStateDown`: the ranges a fold of cell `index` reaches,+/// `levels` deep: up, the innermost range holding it and its parents (`getAllRegionsAtLine`); down, that range and+/// the ranges nested in it less than `levels` deep (`getRegionsInside`).+pub fn fold_ranges(ranges: &[(usize, usize)], index: usize, up: bool, levels: usize) -> Vec<(usize, usize)> {+ let Some(innermost) = section_of(ranges, index) else { return Vec::new() };+ let contains = |outer: (usize, usize), inner: (usize, usize)| outer.0 <= inner.0 && inner.1 <= outer.1;+ let mut reached = vec![innermost];+ if up {+ for &range in ranges.iter().rev() {+ if reached.len() >= levels {+ break;+ }+ if range.0 < reached[reached.len() - 1].0 && contains(range, reached[reached.len() - 1]) {+ reached.push(range);+ }+ }+ return reached;+ }+ let mut parents: Vec<(usize, usize)> = Vec::new();+ for &range in ranges.iter().filter(|range| innermost.0 < range.0 && range.0 < innermost.1) {+ while parents.last().is_some_and(|&parent| !contains(parent, range)) {+ parents.pop();+ }+ parents.push(range);+ if parents.len() < levels {+ reached.push(range);+ }+ }+ reached+}+/// `getCellFirstNonEmptyLine`.fn first_non_empty_line(text: &str) -> String {match text.lines().find(|line| !line.trim().is_empty()) {@@ -215,5 +246,10 @@ mod tests {assert_eq!(section_of(&ranges, 1), Some((0, 4)));assert_eq!(section_of(&ranges, 7), Some((5, 7)));assert_eq!(folding_ranges(&[cell(true, "# only")]), []);+ assert_eq!(fold_ranges(&ranges, 3, false, 1), [(2, 4)]);+ assert_eq!(fold_ranges(&ranges, 3, true, 2), [(2, 4), (0, 4)]);+ assert_eq!(fold_ranges(&ranges, 0, false, 1), [(0, 4)]);+ assert_eq!(fold_ranges(&ranges, 0, false, 2), [(0, 4), (2, 4)]);+ assert_eq!(fold_ranges(&ranges, 7, true, 5), [(5, 7)]);}}diff --git a/native/crates/app/src/workbench/notebook_editor/dnd.rs b/native/crates/app/src/workbench/notebook_editor/dnd.rsindex 4fbf21721d0..032492dc114 100644--- a/native/crates/app/src/workbench/notebook_editor/dnd.rs+++ b/native/crates/app/src/workbench/notebook_editor/dnd.rs@@ -2,7 +2,7 @@//! of the cell under the pointer), its selection range moving with it; Alt copies (`isCopy` on macOS).use gpui::{Context, DragMoveEvent, Render, SharedString, Window, div, prelude::*, px};-use serde_json::json;+use serde_json::{Value, json};use super::super::Workbench;use super::CellRow;@@ -70,8 +70,8 @@ impl Workbench {}}- /// `onCellDrop` and `performCellDropEdits`: the dragged cell, or the selection range holding it, moves (or with Alt- /// is copied) above or below the cell it was dropped on.+ /// `onCellDrop`: the dragged cell, or the selection ranges when it is selected, move above or below the cell it was+ /// dropped on; with Alt the one selection range holding it is copied there (`getCellRangeAroundDragTarget`).pub(super) fn drop_cell(&mut self, tab: u32, over_handle: u64, copy: bool, cx: &mut Context<Self>) {let Some(view) = self.notebook_views.views.get_mut(&tab) else { return };let Some((dragged_handle, target, below)) = view.drop_target.take().filter(|(_, handle, _)| *handle == over_handle) else { return };@@ -86,20 +86,19 @@ impl Workbench {if below {to = rows.iter().find(|row| row.index > over && !row.hidden).map_or(model.cells.len(), |row| row.index);}- // shortcut: the one selection range holding the dragged cell moves, not several ranges; upgrade with multi-range selections.- let (start, end) = editor.selections.iter().copied().find(|(start, end)| *start <= dragged && dragged < *end).unwrap_or((dragged, dragged + 1));if copy {+ let (start, end) = editor.selections.iter().copied().find(|(start, end)| *start <= dragged && dragged < *end).unwrap_or((dragged, dragged + 1));let cells: Vec<_> = model.cells[start..end].iter().map(|cell| self.cell_data(cell)).collect();let focus = if to <= start { to + dragged - start } else { dragged + to - start };self.edit_notebook_cells(&key, vec![json!({ "editType": 1, "index": to, "count": 0, "cells": cells })], Some(focus), cx);return;}- if (start..=end).contains(&to) {- return;+ let (edits, focus, selection) = cell_drop_edits(editor.selections.clone(), editor.focus, dragged, to);+ if self.edit_notebook_cells(&key, edits, Some(focus), cx)+ && let Some(editor) = self.host.notebooks.editors.iter_mut().find(|editor| editor.tab_model_id == tab)+ {+ editor.selections = vec![selection];}- let length = end - start;- let new_index = if end <= to { to - length } else { to };- self.edit_notebook_cells(&key, vec![json!({ "editType": 6, "index": start, "length": length, "newIdx": new_index })], Some(new_index + dragged - start), cx);}/// The insertion indicator (`cell-list-insertion-indicator`): 2px across the list, half the bottom toolbar gap@@ -111,3 +110,56 @@ impl Workbench {Some(div().absolute().left_0().right_0().top(px(top - scroll_top + layout::BOTTOM_TOOLBAR_GAP / 2.)).h(px(2.)).bg(self.color("notebook.cellInsertionIndicator")))}}++/// `performCellDropEdits`: every selection range moves to `to` when the dragged cell is in one, else the dragged+/// cell alone; the `Move` edits go last range first, as the model applies them. Returns the edits, the focus and the+/// selection of the moved cells.+fn cell_drop_edits(mut selections: Vec<(usize, usize)>, mut focus: usize, dragged: usize, mut to: usize) -> (Vec<Value>, usize, (usize, usize)) {+ if selections.is_empty() {+ selections = vec![(focus, focus + 1)];+ }+ if !selections.iter().any(|&(start, end)| start <= dragged && dragged < end) {+ selections = vec![(dragged, dragged + 1)];+ focus = dragged;+ }+ if let Some(&(start, _)) = selections.iter().find(|&&(start, end)| start <= to && to < end) {+ to = start;+ }+ selections.sort_by(|a, b| b.0.cmp(&a.0));+ let (mut moved, mut new_focus, mut insertion, mut last_index) = (0, to, to, to);+ let mut edits = Vec::new();+ for (start, end) in selections {+ let length = end - start;+ let new_index = if end <= insertion { insertion - length } else { insertion };+ if (start..=end).contains(&focus) {+ new_focus = new_index + focus - start;+ }+ // A range below the drop place moved down by the ranges already moved above it.+ let from = if start >= to { start + moved } else { start };+ edits.push(json!({ "editType": 6, "index": from, "length": length, "newIdx": new_index }));+ moved += length;+ if end < insertion {+ insertion -= length;+ }+ last_index = new_index;+ }+ (edits, new_focus, (last_index, last_index + moved))+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn every_selected_range_moves_to_the_drop_place() {+ let indices = |edits: &[Value]| edits.iter().map(|edit| (edit["index"].as_u64().unwrap(), edit["length"].as_u64().unwrap(), edit["newIdx"].as_u64().unwrap())).collect::<Vec<_>>();+ // Cells 0 and 2 selected, 2 dragged below cell 4 (drop index 5).+ let (edits, focus, selection) = cell_drop_edits(vec![(0, 1), (2, 3)], 2, 2, 5);+ assert_eq!(indices(&edits), [(2, 1, 4), (0, 1, 3)]);+ assert_eq!((focus, selection), (4, (3, 5)));+ // A dragged cell outside the selection moves alone.+ let (edits, focus, selection) = cell_drop_edits(vec![(0, 1)], 0, 3, 1);+ assert_eq!(indices(&edits), [(3, 1, 1)]);+ assert_eq!((focus, selection), (1, (1, 2)));+ }+}diff --git a/native/crates/app/src/workbench/notebook_editor/folding.rs b/native/crates/app/src/workbench/notebook_editor/folding.rsindex edc0a245495..30c451ba640 100644--- a/native/crates/app/src/workbench/notebook_editor/folding.rs+++ b/native/crates/app/src/workbench/notebook_editor/folding.rs@@ -31,7 +31,7 @@ impl Workbench {.cursor_pointer().on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation()).on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| {- workbench.set_notebook_fold(tab, index, !collapsed);+ workbench.set_notebook_fold(tab, index, !collapsed, false, 1);workbench.focus_notebook_cell(tab, handle, false, window, cx);})),)@@ -66,7 +66,7 @@ impl Workbench {}))});let expand = button("more", "notebook-folded-expand").ml(px(4.)).on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {- workbench.set_notebook_fold(tab, index, false);+ workbench.set_notebook_fold(tab, index, false, false, 1);cx.notify();}));Some(@@ -83,18 +83,20 @@ impl Workbench {)}- /// `setFoldingStateUp` one level: the innermost section holding cell `index` collapses or expands; a focused cell- /// it hides gives the focus to the nearest visible cell above (`getNearestVisibleCellIndexUpwards`).- pub(super) fn set_notebook_fold(&mut self, tab: u32, index: usize, collapse: bool) {+ /// The innermost section holding cell `index` collapses or expands, with the sections `levels` up or down from+ /// it (`outline::fold_ranges`); a focused cell it hides gives the focus to the nearest visible cell above+ /// (`getNearestVisibleCellIndexUpwards`).+ pub(super) fn set_notebook_fold(&mut self, tab: u32, index: usize, collapse: bool, up: bool, levels: usize) {let Some(editor) = self.host.notebooks.editor(tab) else { return };let Some(model) = self.host.notebooks.model(&editor.notebook) else { return };- let Some((start, _)) = outline::section_of(&self.notebook_folding_ranges(model), index) else { return };- let header = model.cells[start].handle;+ let headers: Vec<_> = outline::fold_ranges(&self.notebook_folding_ranges(model), index, up, levels).iter().map(|(start, _)| model.cells[*start].handle).collect();let view = self.notebook_views.views.entry(tab).or_default();- match collapse {- true => view.collapsed.insert(header),- false => view.collapsed.remove(&header),- };+ for header in headers {+ match collapse {+ true => view.collapsed.insert(header),+ false => view.collapsed.remove(&header),+ };+ }let model = self.host.notebooks.model(&self.host.notebooks.editor(tab).expect("found above").notebook).expect("found above");let rows = self.notebook_rows(tab, model);let editor = self.host.notebooks.editors.iter_mut().find(|editor| editor.tab_model_id == tab).expect("found above");@@ -118,17 +120,19 @@ impl Workbench {}}- /// `NotebookFoldingAction` and `NotebookUnfoldingAction`: `{ index, direction }` or the active cell; a code cell- /// folds nothing downwards. shortcut: `levels` above 1 fold one level, no caller passes more.+ /// `NotebookFoldingAction` and `NotebookUnfoldingAction`: `{ index, levels, direction }` or the active cell; a+ /// code cell folds nothing downwards.fn fold_command(&mut self, args: Option<&Value>, collapse: bool) {let Some(editor) = self.active_notebook_editor() else { return };let (tab, focus) = (editor.tab_model_id, editor.focus);let index = args.and_then(|args| args["index"].as_u64()).map_or(focus, |index| index as usize);let up = args.is_some_and(|args| args["direction"] == "up");+ // `args.levels || 1`: 0 or none is one level.+ let levels = args.and_then(|args| args["levels"].as_u64()).filter(|&levels| levels > 0).map_or(1, |levels| levels as usize);let Some(model) = self.host.notebooks.model(&editor.notebook) else { return };- if model.cells.get(index).is_none_or(|cell| cell.kind == CODE && !up) {+ if model.cells.get(index).is_none_or(|cell| collapse && cell.kind == CODE && !up) {return;}- self.set_notebook_fold(tab, index, collapse);+ self.set_notebook_fold(tab, index, collapse, up, levels);}}diff --git a/native/crates/app/src/workbench/notebook_editor/tests.rs b/native/crates/app/src/workbench/notebook_editor/tests.rsindex ad94ac5f94d..ee5ef9b79a0 100644--- a/native/crates/app/src/workbench/notebook_editor/tests.rs+++ b/native/crates/app/src/workbench/notebook_editor/tests.rs@@ -495,6 +495,8 @@ fn the_outline_header_collapses_and_expands_the_notebook_s_headers(cx: &mut Testassert!(all_collapsed(cx), "Collapse All folds `# Title`; `# Other` is a leaf");workbench.update(cx, |workbench, cx| workbench.set_outline_all_expanded(true, cx));assert!(!all_collapsed(cx));+ let depths = workbench.read_with(cx, |workbench, _| workbench.tree_depths(crate::workbench::list_scroll::ListId::Outline));+ assert_eq!(depths, [0, 1, 0], "the sticky rows read the notebook outline's shown depths");}#[gpui::test]@@ -904,6 +906,15 @@ fn markdown_headers_fold_their_sections(cx: &mut TestAppContext) {assert_eq!(rows(cx).0, [false, true, true, true]);run(&workbench, "notebook.unfold", cx);assert_eq!(rows(cx).0, [false, false, false, true], "the inner section stays collapsed");++ // `levels`: two levels down unfold the section and the one inside it; two levels up fold both again.+ let with_args = |id: &str, args: serde_json::Value, cx: &mut VisualTestContext| {+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command(id, vec![args], window, cx)));+ };+ with_args("notebook.unfold", json!({ "index": 0, "levels": 2 }), cx);+ assert_eq!(rows(cx).0, [false; 4]);+ with_args("notebook.fold", json!({ "index": 3, "levels": 2, "direction": "up" }), cx);+ assert_eq!(rows(cx).1, [Some((true, 3)), None, Some((true, 1)), None]);}/// cellCommands.ts, notebookClipboard.ts and cellEditorOptions.ts on the toolbar's cell.diff --git a/native/crates/app/src/workbench/notebook_outline.rs b/native/crates/app/src/workbench/notebook_outline.rsindex 42864c13ef5..3903a2120c5 100644--- a/native/crates/app/src/workbench/notebook_outline.rs+++ b/native/crates/app/src/workbench/notebook_outline.rs@@ -33,8 +33,8 @@ impl Workbench {false => (self.color("list.inactiveSelectionBackground"), self.theme.color("list.inactiveSelectionForeground")),};let indent = self.tree_indent();- let mut elements = Vec::new();- for (index, row) in rows.iter().enumerate() {+ let render_row = |index: usize, cx: &mut Context<Self>| {+ let row = &rows[index];let entry = &entries[row.entry];let is_selected = selected == Some(row.entry);let icon_color = match focused && is_selected {@@ -57,43 +57,45 @@ impl Workbench {};let icon = (self.setting("outline.icons") != false).then(|| self.outline_entry_icon(model, entry, icon_color, ROW_HEIGHT)).flatten();let cell = entry.cell;- elements.push(- div()- .id(("notebook-outline-row", index))- .h(px(ROW_HEIGHT))- .flex_none()- .flex()- .items_center()- .cursor_pointer()- .mx(px(self.pane_row_inset()))- .rounded(px(4.))- .pl(px(11. + indent * row.depth as f32))- .when(!is_selected, |row| row.hover(|row| row.bg(self.color("list.hoverBackground"))))- .when(is_selected, |row| row.bg(selection).when_some(selection_foreground, |row, color| row.text_color(color)))- .child(twistie)- .child(- div()- // tree.css: the twistie's 6px padding-right less its translateX(3px).- .ml(px(3.))- .flex_1()- .min_w_0()- .flex()- .items_center()- .overflow_hidden()- .whitespace_nowrap()- .children(icon)- .child(format!(" {}", entry.label.replace('\n', "\u{23ce}"))),- )- .on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| {- window.focus(&workbench.outline_pane.focus, cx);- workbench.reveal_notebook_outline_entry(tab, cell, cx);- }))- .into_any_element(),- );- }+ div()+ .id(("notebook-outline-row", index))+ .h(px(ROW_HEIGHT))+ .flex_none()+ .flex()+ .items_center()+ .cursor_pointer()+ .mx(px(self.pane_row_inset()))+ .rounded(px(4.))+ .pl(px(11. + indent * row.depth as f32))+ .when(!is_selected, |row| row.hover(|row| row.bg(self.color("list.hoverBackground"))))+ .when(is_selected, |row| row.bg(selection).when_some(selection_foreground, |row, color| row.text_color(color)))+ .child(twistie)+ .child(+ div()+ // tree.css: the twistie's 6px padding-right less its translateX(3px).+ .ml(px(3.))+ .flex_1()+ .min_w_0()+ .flex()+ .items_center()+ .overflow_hidden()+ .whitespace_nowrap()+ .children(icon)+ .child(format!(" {}", entry.label.replace('\n', "\u{23ce}"))),+ )+ .on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| {+ window.focus(&workbench.outline_pane.focus, cx);+ workbench.reveal_notebook_outline_entry(tab, cell, cx);+ }))+ .into_any_element()+ };+ let elements: Vec<AnyElement> = (0..rows.len()).map(|index| render_row(index, cx)).collect();let tree = div().id("notebook-outline-tree").track_focus(&self.outline_pane.focus).size_full().overflow_y_scroll().track_scroll(&self.outline_pane.scroll).line_height(px(ROW_HEIGHT)).children(elements);- // shortcut: no sticky rows over a notebook's outline, `tree_depths` has none for it; add them with its rows.- Some(div().relative().size_full().child(tree).child(self.list_scroll_layer(super::list_scroll::ListId::Outline, cx)).into_any_element())+ let list = super::list_scroll::ListId::Outline;+ let sticky = self.tree_sticky_rows(list, &rows.iter().map(|row| row.depth).collect::<Vec<_>>());+ let sticky_elements = sticky.iter().map(|sticky_row| render_row(sticky_row.index, cx)).collect();+ let sticky_container = self.tree_sticky_container(list, &sticky, sticky_elements, cx);+ Some(div().relative().size_full().child(tree).child(self.list_scroll_layer(list, cx)).children(sticky_container).into_any_element())}/// outlinePane.ts `updateAllCollapsedCtx` while a notebook editor is active: every top entry is a leaf or collapsed.@@ -105,6 +107,14 @@ impl Workbench {Some(rows.iter().filter(|row| row.depth == 0).all(|row| !row.has_children || !self.outline_row_expanded(editor.tab_model_id, &row.entry.to_string())))}+ /// The shown rows' depths while a notebook editor is active, for the sticky rows.+ pub(super) fn notebook_outline_depths(&self) -> Option<Vec<usize>> {+ let editor = self.active_notebook_editor()?;+ let model = self.host.notebooks.model(&editor.notebook)?;+ let (headers_only, code_cells) = self.notebook_outline_filters();+ Some(self.notebook_outline_rows(editor.tab_model_id, &self.notebook_outline(model), headers_only, code_cells).iter().map(|row| row.depth).collect())+ }+fn notebook_outline_filters(&self) -> (bool, bool) {(self.setting("notebook.outline.showMarkdownHeadersOnly") != false, self.setting("notebook.outline.showCodeCells") == true)}diff --git a/native/crates/app/src/workbench/tree_guides.rs b/native/crates/app/src/workbench/tree_guides.rsindex e035ab084bd..c583c80ad74 100644--- a/native/crates/app/src/workbench/tree_guides.rs+++ b/native/crates/app/src/workbench/tree_guides.rs@@ -178,6 +178,8 @@ impl Workbench {tree.set_selection(&row.path);window.focus(&self.explorer.focus.clone(), cx);}+ // A notebook outline's selection is its active cell's entry; the press scrolls and focuses the tree.+ ListId::Outline if self.active_notebook_editor().is_some() => window.focus(&self.outline_pane.focus.clone(), cx),ListId::Outline => {let Some(id) = self.outline_shown_rows().into_iter().nth(index).map(|(id, _)| id) else { return };self.outline_pane.focused = Some(id.clone());@@ -198,7 +200,7 @@ impl Workbench {pub(super) fn tree_depths(&self, list: ListId) -> Vec<usize> {match list {ListId::Explorer => self.folder.as_ref().map(|tree| tree.rows().iter().map(|row| row.depth).collect()).unwrap_or_default(),- ListId::Outline => self.outline_shown_rows().into_iter().map(|(_, depth)| depth).collect(),+ ListId::Outline => self.notebook_outline_depths().unwrap_or_else(|| self.outline_shown_rows().into_iter().map(|(_, depth)| depth).collect()),ListId::Search => self.search.rows(&self.search_folders(), Some(&self.collapse_results())).iter().map(|row| row.depth).collect(),ListId::KeybindingsTable | ListId::SettingsTree | ListId::EditorTabs { .. } | ListId::Notebook(_) | ListId::CommentThread { .. } | ListId::MarkerMessage | ListId::ParameterHints => Vec::new(),}diff --git a/port/ledger.md b/port/ledger.mdindex 70026e53913..d94b6fe7dab 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -513,7 +513,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/contrib/meteredConnection | workbench contribution | M19 | verified | | the metered warning status entry and Configure Metered Connection (workbench/power.rs); port/tools/shell-check (port/fixtures/extensions/shell-tests, 6/6); cargo test -p app metered_connection || workbench/contrib/modernUI | workbench contribution | M11 | verified | | the modern layout only: the classic layout (`workbench.experimental.modernUI: false`) is removed by Artur's decision (port/notes.md Modern UI); `window.density.layout` compact and the Manage menu's Layout Density (cargo test -p app -- compact_density layout_density; ui-pair m11/layout-density.json in both densities with SETTINGS `{"window.density.layout": "compact"}`, port/results/layout-density.md) || workbench/contrib/multiDiffEditor | workbench contribution | M14 | verified | | multi_diff_editor.rs and workbench/editor_view/multi_diff_editor_view.rs: `_workbench.openMultiDiffEditor`, SCM group (following the group's splices, each kept file with its state) and history item sources, Open File with the history item's `goToFileEditorTitle`, file toolbar, change navigation, collapse, binary placeholder, unchanged bars that click or drag with the line below kept in place and the hidden range's outline breadcrumbs (cargo test -p app unchanged_bars_drag), the layout debug log in the side group with a JSON patch line per change, the file list's Files View & Position sides, its sash with the stored width and hiding below 560px, View as List/Tree with the diffs in the list's order, each file's 35px diff gutter with Revert Block, the diff editor's line number lane, the `noCards` variant, first change selected and focused on open: cargo test -p app multi_diff. Each file side is its own code editor (workbench/code_editors.rs): a press focuses it, the modified side takes typing, undo, selection, IME, find and suggest, the host gets the file's edit, the edit recomputes the file's diff and makes the tab dirty and pinned, the dirty file opens as an inactive tab after 800ms (textFileEditorTracker.ts), the focused side's cursor blinks, every drawn side has its own color decorators, bracket pair colors come from the model: cargo test -p app a_file_side_is_a_code_editor every_drawn_file_side; ui-pair `steps-multi-diff-edit.json` (typed, undone, find) matches but for the reference's TypeScript diagnostics (port/notes.md, Comments in diff editors) |-| workbench/contrib/notebook | workbench contribution | M17 | ported | [3 M] notebook_outline.rs:95, folding.rs:122, dnd.rs:89, m17d: sticky rows; levels above 1; multi-range drag; stale cell toolbar actions, restored status bar items, unfocused cell hovers, breadcrumbs `...` | NotebookProviderInfoStore's memento lists notebook types until the extensions register (cargo test -p app markdown_editor_files_offer). compressOutputItemStreams (cargo test -p app notebook::tests::stream_compression). verified (session m17d): cargo test -p app -- notebook kernel renderer backup interactive repl outline quick_input explorer list_scroll walkthrough 288/0 (incl. the_notebook_list_scrolls_beyond_its_last_cell_with_the_wheel, the_mouse_over_a_longer_unfocused_cell_reaches_that_cell, overview_ruler); api-tests `MOCHA_GREP="Notebook|ipynb|Interactive Window|Ensure tabs getter"` 41/10/0 three runs in a row at 499a612a62f (the 10 pending are upstream skips; `Ensure tabs getter` failed in 2 of 3 runs before the exthost fix that holds workbench answers until the queue before them is sent); ui-pairs m17 notebook-open, -keys-outline, -output-toolbar, -kernel-picker, -restore (/tmp/m17f, /tmp/m17g), -cell-click and -scroll match; -toolbars and -find rerun on the GUI lanes at 991cb455f74 (gui-vm1 and gui-vm2, port and reference from the same run, Studio /tmp/m17i-notebook-*): menus, find highlights and overview ruler marks within 1 device px of the reference; differences named in port/notes.md session m17d; model (notebook.rs, notebookTextModel.ts edits, events, transient options, stream output merging), kernels and executions (notebook/kernels.rs), notebook service and resolver (workbench/notebooks.rs): cargo test -p app notebook; api-tests notebook suites 40/8/0 as the reference. Notebook editor (workbench/notebook_editor.rs, notebook/layout.rs): cells as code editors over their text models (the focused cell's is the group's code editor), markdown previews and outputs in the back layer webview, toolbar (+ Code, + Markdown, Run All, kernel picker), insert toolbar between cells, run gutter with execution order and state, cell toolbar (edit, stop editing, delete), Cell N of M status, notebook undo/redo over cell edits and cell text edits: cargo test -p app notebook (layout against the reference's measurements, undo order); ui-pair m17/notebook-open. Breadcrumbs with the notebook outline and the editor type picker, the Outline view, cell status bar items, cell list keyboard navigation, API cell edits on the undo stack, Save and Save As (untitled), dirty close prompt, host references let go after 3 minutes (port/notes.md milestone 17): cargo test -p app notebook (23). Hot exit backups through the serializer (`notebook/<viewType>/<viewType>` working copies, restored in the background): cargo test -p app a_dirty_notebook_backs_up; `notebook.cell.changeLanguage` from the cell status bar and Cmd+K M (language picker, kind changes): cargo test -p app the_cell_language_picker. The output `...` toolbar (cellOutput.ts `_attachToolbar`, MenuId.NotebookOutputToolbar: Clear Cell Outputs, Copy Cell Output, Save Image, Show Empty Outputs; Change Presentation with the session display order and preferred renderers; hidden empty outputs and the 28px minimum output height; workbench/notebook_editor/outputs.rs): cargo test -p app the_output_toolbar_menu, renderers; ui-pair m17/notebook-output-toolbar.json. Notebook editors come back after a reload (NotebookEditorSerializer): cargo test -p app a_notebook_editor_comes_back. The title's Customize Notebook... gear: cargo test -p app the_customize_notebook_submenu, ui-pair m17/notebook-toolbars.json. Cell toolbars from MenuId.NotebookCellTitle and NotebookCellDelete (inline groups as buttons, the `...` dropdown with Cut/Copy/Paste Cell, Insert Cell, Change Cell to Code/Markdown, Join, Copy Cell Down, Move (drag and drop), Show Cell Line Numbers, Toggle Cell Toolbar Position; `notebookMissingKernelExtension` and the kernel counts; interactive and REPL cells use InteractiveCellTitle; workbench/notebook_editor/cell_actions.rs), the notebook toolbar `...` (MenuId.NotebookToolbar), Run Cells In Section, the markdown fold chevron, folded hint and Fold/Unfold Cell (foldingModel.ts ranges, notebook/outline.rs `folding_ranges`; workbench/notebook_editor/folding.rs), `Spaces: N` while a code cell is focused, no `editorLangId` title items: cargo test -p app the_cell_toolbar, markdown_headers_fold, headings_fold, split_points, the_toolbar_position; cell drag and drop by the left gutter, with an insertion indicator and Alt-copy: `cargo test -p app a_cell_dragged_by_its_left_column_moves_or_copies_to_the_drop_place`. Find, the restored view state and clicks on a cell's text are done since (port/notes.md sessions m17b and m17d) |+| workbench/contrib/notebook | workbench contribution | M17 | verified | | NotebookProviderInfoStore's memento lists notebook types until the extensions register (cargo test -p app markdown_editor_files_offer). compressOutputItemStreams (cargo test -p app notebook::tests::stream_compression). verified (session m17d): cargo test -p app -- notebook kernel renderer backup interactive repl outline quick_input explorer list_scroll walkthrough 288/0 (incl. the_notebook_list_scrolls_beyond_its_last_cell_with_the_wheel, the_mouse_over_a_longer_unfocused_cell_reaches_that_cell, overview_ruler); api-tests `MOCHA_GREP="Notebook|ipynb|Interactive Window|Ensure tabs getter"` 41/10/0 three runs in a row at 499a612a62f (the 10 pending are upstream skips; `Ensure tabs getter` failed in 2 of 3 runs before the exthost fix that holds workbench answers until the queue before them is sent); ui-pairs m17 notebook-open, -keys-outline, -output-toolbar, -kernel-picker, -restore (/tmp/m17f, /tmp/m17g), -cell-click and -scroll match; -toolbars and -find rerun on the GUI lanes at 991cb455f74 (gui-vm1 and gui-vm2, port and reference from the same run, Studio /tmp/m17i-notebook-*): menus, find highlights and overview ruler marks within 1 device px of the reference; differences named in port/notes.md session m17d; model (notebook.rs, notebookTextModel.ts edits, events, transient options, stream output merging), kernels and executions (notebook/kernels.rs), notebook service and resolver (workbench/notebooks.rs): cargo test -p app notebook; api-tests notebook suites 40/8/0 as the reference. Notebook editor (workbench/notebook_editor.rs, notebook/layout.rs): cells as code editors over their text models (the focused cell's is the group's code editor), markdown previews and outputs in the back layer webview, toolbar (+ Code, + Markdown, Run All, kernel picker), insert toolbar between cells, run gutter with execution order and state, cell toolbar (edit, stop editing, delete), Cell N of M status, notebook undo/redo over cell edits and cell text edits: cargo test -p app notebook (layout against the reference's measurements, undo order); ui-pair m17/notebook-open. Breadcrumbs with the notebook outline and the editor type picker, the Outline view, cell status bar items, cell list keyboard navigation, API cell edits on the undo stack, Save and Save As (untitled), dirty close prompt, host references let go after 3 minutes (port/notes.md milestone 17): cargo test -p app notebook (23). Hot exit backups through the serializer (`notebook/<viewType>/<viewType>` working copies, restored in the background): cargo test -p app a_dirty_notebook_backs_up; `notebook.cell.changeLanguage` from the cell status bar and Cmd+K M (language picker, kind changes): cargo test -p app the_cell_language_picker. The output `...` toolbar (cellOutput.ts `_attachToolbar`, MenuId.NotebookOutputToolbar: Clear Cell Outputs, Copy Cell Output, Save Image, Show Empty Outputs; Change Presentation with the session display order and preferred renderers; hidden empty outputs and the 28px minimum output height; workbench/notebook_editor/outputs.rs): cargo test -p app the_output_toolbar_menu, renderers; ui-pair m17/notebook-output-toolbar.json. Notebook editors come back after a reload (NotebookEditorSerializer): cargo test -p app a_notebook_editor_comes_back. The title's Customize Notebook... gear: cargo test -p app the_customize_notebook_submenu, ui-pair m17/notebook-toolbars.json. Cell toolbars from MenuId.NotebookCellTitle and NotebookCellDelete (inline groups as buttons, the `...` dropdown with Cut/Copy/Paste Cell, Insert Cell, Change Cell to Code/Markdown, Join, Copy Cell Down, Move (drag and drop), Show Cell Line Numbers, Toggle Cell Toolbar Position; `notebookMissingKernelExtension` and the kernel counts; interactive and REPL cells use InteractiveCellTitle; workbench/notebook_editor/cell_actions.rs), the notebook toolbar `...` (MenuId.NotebookToolbar), Run Cells In Section, the markdown fold chevron, folded hint and Fold/Unfold Cell (foldingModel.ts ranges, notebook/outline.rs `folding_ranges`; workbench/notebook_editor/folding.rs), `Spaces: N` while a code cell is focused, no `editorLangId` title items: cargo test -p app the_cell_toolbar, markdown_headers_fold, headings_fold, split_points, the_toolbar_position; cell drag and drop by the left gutter, with an insertion indicator and Alt-copy: `cargo test -p app a_cell_dragged_by_its_left_column_moves_or_copies_to_the_drop_place`. Find, the restored view state and clicks on a cell's text are done since (port/notes.md sessions m17b and m17d). Fold and unfold with `levels` and `direction: up` (foldingController setFoldingStateUp/Down, notebook/outline.rs `fold_ranges`): cargo test -p app markdown_headers_fold_their_sections, headings_fold; a drag of a selected cell moves every selection range (performCellDropEdits, dnd.rs `cell_drop_edits`): cargo test -p app every_selected_range_moves_to_the_drop_place; sticky rows over the notebook outline: cargo test -p app the_outline_header_collapses_and_expands_the_notebook_s_headers. The m17d differences left (stale cell toolbar, restored status bar items, breadcrumbs `…`) are reference quirks not copied, port/notes.md session m17d || workbench/contrib/onboarding | workbench contribution | M19 | removed | | the only registered tours are the Agents window ones (src/vs/sessions/contrib/onboardingTours): no AI by decision (port/notes.md) || workbench/contrib/opener | workbench contribution | M12 | verified | | workbench/opener.rs open_folder_link: a link to a workspace folder reveals it in the Explorer; verified at port-m12b-verify: cargo test -p app opener 4/4 || workbench/contrib/outline | workbench contribution | M13 | verified | | Outline view (workbench/outline_pane.rs): messages, loading after 100ms, symbols by position with `outline.show*`, `outline.icons`, `outline.collapseItems`, problem colors and badges, twisties, Up/Down/Left/Right/Enter/Space, click opens at the name and double click selects the range; cargo test -p app outline_pane. A diff editor shows "The active editor cannot provide outline information." (a diff input has no `getOriginalUri`) and keeps the breadcrumbs' symbols: cargo test -p app the_compare_commands_open_diff_editors; `outline.focus` over a message keeps the focus: cargo test -p app focus_view_commands_open_the_explorer_pane_and_focus_it; ui-pair m12/compare-outline.json matches the reference. Title actions (workbench/outline_actions.rs): Collapse All/Expand All, Follow Cursor, Filter on Type, Sort By: Position/Name/Category in `outline/state` (cargo test -p app outline). ui-pair steps-outline.json (port/results/language-features.md): the header actions and rows match. Find (workbench/outline_find.rs, the Explorer's find widget): typing filters or highlights the symbols, with "No results found.", all rows expanded while a pattern filters and the expansion, focus and selection restored after; cargo test -p app find_filters_or_highlights_the_symbols. The tree's focus apart from its selection, Page Up/Down, `list.focusParent`, `list.collapseAllToFocus`, `list.showHover` ("name (kind)"), `list.toggleSelection`, `list.clear`, scroll and sticky rows: cargo test -p app the_keys_move_the_focus_and_the_list_commands_act_on_it. Row contents 30px in and the detail after the name's exact width: cargo test -p app -- a_row_s_contents_start_30px_into_the_row the_detail_follows_the_name_s_exact_width. ui-pair m12/outline-find.json (filter, no results, tree focus, focus moved): the Outline matches, the find widget's 155.5px input and its message box included; left is the editor's npm "Debug" code lens. Descriptions of every icon label (workbench/icon_label.rs `label_description`: 0.9em, 0.5em margin, on the name's baseline): cargo test -p app a_description_is_0_9em; ui-pair search and quick open rows match |diff --git a/port/notes.md b/port/notes.mdindex 7f11180b200..8f2525c707a 100644--- a/port/notes.md+++ b/port/notes.md@@ -788,7 +788,7 @@ Handoff (branch `port-m18b-gallery`, after `docs(port): record milestone 18 exte- Customize Notebook... (layoutActions.ts): the editor title's gear (`Entry::Submenu` of MenuId.NotebookEditorLayoutConfigure, editor_view.rs `submenu_button`) with Customize Notebook Layout (Settings at `@tag:notebookLayout`), Line Numbers (`notebook.toggleLineNumbers`, also in the palette) and Breadcrumbs, short titles as toolbar dropdowns render them: `cargo test -p app the_customize_notebook_submenu`; ui-pair m17/notebook-toolbars.json step title-gear matches (Toggle Cell Toolbar Position added in the third pass).- Session m17b (third pass): cell toolbars, overflow and notebook toolbar `...`, Toggle Cell Toolbar Position (also in the title gear: from there it gets no `ui` context and does nothing, as upstream), Run Cells In Section, fold chevron and Fold/Unfold Cell, `Spaces: N`, REPL hot exit, no markdown preview title action in notebooks (the title context drops `editorLangId`, which upstream lives in the cell editors' scoped context). Checks: `cargo test -p app -- --skip view_locations` 2560 passed (`view_locations::tests::outline_moved_to_a_new_panel_entry...` aborts the run: its terminal's `pty-read` thread drops a task on the test scheduler, from port-integrate); api-tests `MOCHA_GREP="Interactive Window|Notebook|Ensure tabs getter|vscode API - window"` 80/10/0; ui-pairs m17 (all seven runs in /tmp/m17b-all and /tmp/m17b-2 on the Studio). Differences left: the restored notebook focuses its first cell where the reference brings back the focused cell, its editor focus and selection (INotebookEditorViewState); after the markup `...` menu closes the port can keep that cell's toolbar while the reference shows only its chevron (the hover state from the webview's `mouseEnterMarkupCell`); the notebook toolbar `...` has no pressed background while its menu is open; the REPL status bar (ledger row). Clicks on a code cell's text (fixed in m17b fourth pass): the lines of an inactive cell editor stop the press and place the cursor in the active editor, so the cell never took the focus (a GUI trace showed the press reach the cell in the capture phase only); the cell editor now focuses its cell in the capture phase (`cargo test -p app a_click_on_the_text_of_another_code_cell_edits_that_cell`, ui-pair m17/notebook-cell-click.json). Breadcrumb separators now match within 5px.- Session m17b (fourth pass): notebook find (`workbench/notebook_editor/find.rs`, notebookFindWidget.ts, findModel.ts): Cmd+F in the list or a cell editor (`actions.find` routes to it in a notebook editor), the widget at the list's top right under the toolbar, cell sources searched natively and rendered markdown and outputs by the preloads (`find`, `didFind`, `findHighlightCurrent`), the four filters as a checked menu, Enter and Shift+Enter, replace and replace all on sources (markup cells with matches open in edit mode while the replace input shows), research on each edit, decorations in the cell editors. The back layer webview draws over GPUI, so its clip view gets a CALayer mask with a hole where the widget lies, and presses there go to GPUI (`ClipView::place` `hole`). Checks: `cargo test -p app notebook_find`, ui-pair m17/notebook-find.json (typed, next, output: count, match highlights in a code cell and an output, webview current match as the reference). Not done: the widget's resize sash, Find in Selection (shown, inert), the `+` count past 1000 in the webview. Notebook view state (`NotebookEditorViewState` in `memento/workbench.editor.notebook`): focused cell, `editorFocused`, scroll, editing cells, each cell editor's view state, saved on close and shutdown, loaded for a new editor: `cargo test -p app a_reopened_notebook_editor_brings_back`. The focused cell's editor with the keyboard has the `notebook.focusedEditorBorder` border (ui-pair m17/notebook-cell-click.json). A markup cell's toolbar goes when its `...` menu opens (the hidden webview never sends `mouseLeaveMarkupCell`, now handled too): `cargo test -p app a_markdown_cell_toolbar_goes_with_its_more_menu`; ui-pair notebook-toolbars code-toolbar still shows it, because the press at (1000,160) lands in the markup preview and hovers it in the port, not in the reference (open). With a cell editor focused by a click the reference's cell toolbar shows only `...` and delete; the port shows all (open). REPL input status bar: the input's EOL only, then the list's indentation, EOL and `Cell N of M` (seen in the reference): `cargo test -p app a_notebook_shown_as_repl`. The cell toolbar's Share submenu holds github's Copy vscode.dev Link in a GitHub repository: `cargo test -p app the_github_share_items_fill_the_share_submenus`.-- Session m17d: the MRU kernel picker (`workbench/kernel_picker.rs`), `onRenderer:` activation, the outline's Filter Entries, `notebook.cellToolbarVisibility` click, the notebook and interactive status bar items, restored editors taking the focus, REPL scratchpad backups, dirty notebooks in the Explorer badge. The cell list's vertical scrollbar and `NotebookOverviewRuler` (`workbench/notebook_editor/overview_ruler.rs`): the list scrolls as a workbench list (`ListId::Notebook`, list_scroll.rs: wheel sensitivity, smooth scrolling, the fading 10px scrollbar, the top shadow), the back layer's `did-scroll-wheel` takes the same path, and the list scrolls until 50px of the last cell are left (`paddingBottom` of `editor.scrollBeyondLastLine`, not in interactive and REPL history lists). The webview clip leaves the list's right 10px to the scrollbar and ruler (the cells end 16px from it). The ruler draws find's decorations in the center lane as notebookOverviewRuler.ts: scaled by the editor height with the 26px toolbar over the scroll height, a line at most the editor line height in canvas pixels (half of it on a 2x display). An unfocused cell editor has a cover that takes the mouse: a press focuses the cell and places its cursor (`click_active_editor_at`, shared with the playground); its lines answered for the active editor before, and a hover past the focused cell's last line panicked. Checks: `cargo test -p app the_notebook_list_scrolls_beyond, the_mouse_over_a_longer_unfocused_cell, overview_ruler`; ui-pair m17/notebook-find.json (ruler marks at the reference's place), m17/notebook-scroll.json. Differences named, not copied: the cell title toolbar keeps stale actions until a menu context key changes (the reference shows only `...` and delete on a cell focused by keyboard or click); the reference's breadcrumbs show `…` for a code cell until its content changes; the webview hides under menus and quick input (native layer, see above); a restored notebook's status bar in the reference leaves out the cell editor's items (`Ln, Col`, `LF`) though the cell editor has the focus; Add Cell Output to Chat (AI removed); unfocused cell editors show no hovers (upstream each cell is a full editor). Hovering a markdown preview then Down moves the focused cell in both (ui-pair hover-down, the open question of m17c closed).+- Session m17d: the MRU kernel picker (`workbench/kernel_picker.rs`), `onRenderer:` activation, the outline's Filter Entries, `notebook.cellToolbarVisibility` click, the notebook and interactive status bar items, restored editors taking the focus, REPL scratchpad backups, dirty notebooks in the Explorer badge. The cell list's vertical scrollbar and `NotebookOverviewRuler` (`workbench/notebook_editor/overview_ruler.rs`): the list scrolls as a workbench list (`ListId::Notebook`, list_scroll.rs: wheel sensitivity, smooth scrolling, the fading 10px scrollbar, the top shadow), the back layer's `did-scroll-wheel` takes the same path, and the list scrolls until 50px of the last cell are left (`paddingBottom` of `editor.scrollBeyondLastLine`, not in interactive and REPL history lists). The webview clip leaves the list's right 10px to the scrollbar and ruler (the cells end 16px from it). The ruler draws find's decorations in the center lane as notebookOverviewRuler.ts: scaled by the editor height with the 26px toolbar over the scroll height, a line at most the editor line height in canvas pixels (half of it on a 2x display). An unfocused cell editor has a cover that takes the mouse: a press focuses the cell and places its cursor (`click_active_editor_at`, shared with the playground); its lines answered for the active editor before, and a hover past the focused cell's last line panicked. Checks: `cargo test -p app the_notebook_list_scrolls_beyond, the_mouse_over_a_longer_unfocused_cell, overview_ruler`; ui-pair m17/notebook-find.json (ruler marks at the reference's place), m17/notebook-scroll.json. Differences named, not copied: the cell title toolbar keeps stale actions until a menu context key changes (the reference shows only `...` and delete on a cell focused by keyboard or click); the reference's breadcrumbs show `…` for a code cell until its content changes; the webview hides under menus and quick input (native layer, see above); a restored notebook's status bar in the reference leaves out the cell editor's items (`Ln, Col`, `LF`) though the cell editor has the focus; Add Cell Output to Chat (AI removed). Unfocused cell editors show their hovers since (`the_mouse_over_an_unfocused_cell_shows_its_hover`). Hovering a markdown preview then Down moves the focused cell in both (ui-pair hover-down, the open question of m17c closed).- Views audit (ui-pairs m17/notebook-open, notebook-keys-outline, notebook-output-toolbar, notebook-toolbars, notebook-cli at 8f138e76960, Studio /tmp/views-ipynb and /tmp/views-ipynb2): the "differences left" above now match: breadcrumbs (also `sample.ipynb > …` and the chain after keyboard moves), Run All `...`, output `...` and its menu, fold chevron, code and markup cell toolbars, title gear, focus bars over the outputs, `Spaces: 4`, the Outline filter action, and on the command line the JSON breadcrumbs `> …` and the `{ }` language status. Left: the reference shows only `...` and delete on the markup cell right after opening (its stale toolbar, named above, not copied); the Output menu leaves out Add Cell Output to Chat (AI removed); in one of two runs a click on the markdown preview then Down kept Cell 1 focused (ledger row extension/ipynb). The reference showed git's "A git repository was found in the parent folders" prompt within 6 s of notebook-cli, the port did not (fixture inside this repository; not notebook code).- Handoff (notebooks), what is left: the restored focus above, notebook find, an interactive window restart pair, (4) welcomeWalkthrough (Editor Playground) on the stacked editors: done in port-m19-walkthrough (Editor Playground above).