Visual Studio Code, rebuilt in Rust
Rust
feat(editor): track pairs inserted by snippets as auto-closed
rokartur6e059d14a731
diff --git a/native/crates/app/src/editor/auto_closing.rs b/native/crates/app/src/editor/auto_closing.rsindex 72e21960913..b86c4906212 100644--- a/native/crates/app/src/editor/auto_closing.rs+++ b/native/crates/app/src/editor/auto_closing.rs@@ -8,7 +8,7 @@ use textmate::StandardTokenType;use super::OpenEditor;use super::auto_indent::{AutoIndent, parse_regex};use super::cursor::{Position, Selection};-use super::edit::{ContentChanged, CursorEdit, EditKind, Replace, TYPED};+use super::edit::{ContentChanged, CursorEdit, EditKind, EditReason, Replace, TYPED};use super::word_operations::{CharClass, DEFAULT_WORD_SEPARATORS, WordClassifier};/// characterPair.ts `DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED_QUOTES` and `..._BRACKETS`.@@ -255,6 +255,32 @@ impl OpenEditor {change}+ /// cursor.ts `executeEdits` from a snippet or a suggestion: when every edit's text ends in the close of a one-char+ /// pair after its open, those closes are remembered as auto-closed (`_findAutoClosingPairs`).+ pub fn execute_edits_tracking_pairs(&mut self, edits: Vec<(Position, Position, String, bool)>, end_selections: Option<Vec<Selection>>, reason: EditReason, pairs: &[(String, String)]) -> Option<ContentChanged> {+ let Some(indices) = find_auto_closing_pairs(&edits, pairs) else { return self.execute_edits(edits, end_selections, reason) };+ let mut by_position: Vec<_> = edits.iter().zip(indices).map(|((start, end, text, _), indices)| (*start, *end, text.chars().count(), indices)).collect();+ by_position.sort_by_key(|edit| edit.0);+ let change = self.execute_edits(edits, end_selections, reason)?;+ // Where each text landed: lines move up by the line breaks the earlier edits removed, columns move only after+ // an earlier edit that ended on the same line.+ let mut action = AutoClosedAction::default();+ let (mut removed_lines, mut previous): (usize, Option<(Position, usize)>) = (0, None);+ for (start, end, length, (open, close)) in by_position {+ let column = match previous {+ Some((previous_end, new_end_column)) if previous_end.line == start.line => new_end_column + start.column - previous_end.column,+ _ => start.column,+ };+ let line = start.line - removed_lines;+ action.characters.push((Position::new(line, column + close), Position::new(line, column + close + 1)));+ action.enclosing.push((Position::new(line, column + open), Position::new(line, column + close + 1)));+ removed_lines += end.line - start.line;+ previous = Some((end, column + length));+ }+ self.auto_closed.push(action);+ Some(change)+ }+/// `getAutoClosingPair` for typing `ch` at every cursor, all empty: the pair whose open it completes, with the close/// to insert.pub(super) fn auto_closing_pair(&self, ch: char, auto: AutoIndent) -> Option<(String, String)> {@@ -430,5 +456,32 @@ fn is_before_closing_brace(pairs: &[Pair], after: &str) -> bool {!pairs.iter().any(|pair| starts_with(&pair.open)) && pairs.iter().any(|pair| starts_with(&pair.close))}++/// `_findAutoClosingPairs`: per edit, the char indices of the open and the close of the one-char pair whose close is+/// the text's last closing char, or nothing when one edit has no such pair or a line break.+fn find_auto_closing_pairs(edits: &[(Position, Position, String, bool)], pairs: &[(String, String)]) -> Option<Vec<(usize, usize)>> {+ if edits.is_empty() {+ return None;+ }+ let mut indices = Vec::new();+ for (_, _, text, _) in edits {+ if text.is_empty() || text.contains('\n') {+ return None;+ }+ let chars: Vec<char> = text.chars().collect();+ let close_index = chars.iter().rposition(|c| ")]}>'\"`".contains(*c))?;+ let close = chars[close_index];+ let mut candidates = pairs.iter().filter(|(open, pair_close)| open.chars().count() == 1 && pair_close.chars().eq([close]));+ let (open, _) = candidates.next()?;+ if candidates.next().is_some() {+ return None;+ }+ let open = open.chars().next().expect("a one-char open");+ let open_index = chars[..close_index].iter().rposition(|&c| c == open)?;+ indices.push((open_index, close_index));+ }+ Some(indices)+}+#[cfg(test)]mod tests;diff --git a/native/crates/app/src/editor/auto_closing/tests.rs b/native/crates/app/src/editor/auto_closing/tests.rsindex ca2e2def8cd..e357efe9d79 100644--- a/native/crates/app/src/editor/auto_closing/tests.rs+++ b/native/crates/app/src/editor/auto_closing/tests.rs@@ -656,3 +656,42 @@ fn issue_78527_does_not_close_quote_on_odd_count() {assert_eq!(cursor.line(1), expected, "{ch}");}}++fn auto_closing_pairs(cursor: &Cursor) -> Vec<(String, String)> {+ cursor.languages.rules("testLanguage").expect("configured").auto_closing_pairs.clone()+}++#[test]+fn issue_78975_parentheses_swallowing_does_not_work_when_parentheses_are_inserted_by_autocomplete() {+ let mut cursor = Cursor::new(auto_closing_language(), &["<div id"]);+ cursor.select(&[(1, 8)]);+ let pairs = auto_closing_pairs(&cursor);+ let edits = vec![(Position::new(0, 5), Position::new(0, 7), "id=\"\"".to_string(), false)];+ cursor.editor.execute_edits_tracking_pairs(edits, Some(vec![Selection::caret(Position::new(0, 9))]), EditReason::Unknown("snippet"), &pairs);+ assert_eq!(cursor.line(1), "<div id=\"\"");+ cursor.type_text("a");+ assert_eq!(cursor.line(1), "<div id=\"a\"");+ cursor.type_text("\"");+ assert_eq!(cursor.line(1), "<div id=\"a\"");+}++#[test]+fn issue_315131_parentheses_inserted_by_a_suggestion_are_tracked_as_auto_closed() {+ let mut cursor = Cursor::new(auto_closing_language(), &["flo"]);+ cursor.select(&[(1, 4)]);+ let pairs = auto_closing_pairs(&cursor);+ let edits = vec![(Position::new(0, 0), Position::new(0, 3), "floor()".to_string(), false)];+ cursor.editor.execute_edits_tracking_pairs(edits, Some(vec![Selection::caret(Position::new(0, 6))]), EditReason::Unknown("suggest"), &pairs);+ cursor.delete_left(false);+ assert_eq!(cursor.line(1), "floor");+}++#[test]+fn pairs_from_several_edits_on_one_line_are_tracked_where_they_land() {+ let mut cursor = Cursor::new(auto_closing_language(), &["a b"]);+ let pairs = auto_closing_pairs(&cursor);+ let edits = vec![(Position::new(0, 0), Position::new(0, 1), "f()".to_string(), false), (Position::new(0, 2), Position::new(0, 3), "g()".to_string(), false)];+ cursor.editor.execute_edits_tracking_pairs(edits, Some(vec![Selection::caret(Position::new(0, 2)), Selection::caret(Position::new(0, 6))]), EditReason::Unknown("snippet"), &pairs);+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "f() g()");+}diff --git a/native/crates/app/src/workbench/bulk_text_edits.rs b/native/crates/app/src/workbench/bulk_text_edits.rsindex 6b379350b0e..dff07ead7ed 100644--- a/native/crates/app/src/workbench/bulk_text_edits.rs+++ b/native/crates/app/src/workbench/bulk_text_edits.rs@@ -91,7 +91,8 @@ impl Workbench {let templates: Vec<String> = replaces.iter().map(|&(_, _, text, is_snippet, _, _)| if is_snippet { text.to_string() } else { escape_snippet(text) }).collect();let snippets: Vec<_> = replaces.iter().zip(&templates).map(|(&(start, end, _, _, keep_whitespace, _), template)| (start, end, template.as_str(), keep_whitespace)).collect();let (edits, selections, _) = snippet_edits(model, &self.languages, &snippets, clipboard.as_deref());- model.execute_edits(edits, Some(selections), EditReason::Unknown("snippet"))+ let pairs = self.languages.rules(&model.document().language_id).map(|rules| rules.auto_closing_pairs.as_slice()).unwrap_or_default();+ model.execute_edits_tracking_pairs(edits, Some(selections), EditReason::Unknown("snippet"), pairs)} else if in_active_editor {// `_createEditsTasks`: the active editor's edits are made more minimal, in runs split by edits with metadata.let mut edits = Vec::new();diff --git a/native/crates/app/src/workbench/snippet_controller.rs b/native/crates/app/src/workbench/snippet_controller.rsindex a241d64316a..6366d97f019 100644--- a/native/crates/app/src/workbench/snippet_controller.rs+++ b/native/crates/app/src/workbench/snippet_controller.rs@@ -57,7 +57,8 @@ impl Workbench {let (edits, selections, texts) = snippet_edits(editor, &self.languages, insert.snippets, insert.clipboard);let trivial = texts.iter().all(|text| text.stops.iter().all(|(index, _)| *index == 0));let merging = editor.snippet_session.is_some();- let change = editor.execute_edits(edits, Some(selections), EditReason::Unknown(insert.reason));+ let pairs = self.languages.rules(&editor.document().language_id).map(|rules| rules.auto_closing_pairs.as_slice()).unwrap_or_default();+ let change = editor.execute_edits_tracking_pairs(edits, Some(selections), EditReason::Unknown(insert.reason), pairs);let replaced: Vec<(Position, Position, &str)> = insert.snippets.iter().zip(&texts).map(|(snippet, text)| (snippet.0, snippet.1, text.text.as_str())).collect();let starts = starts_after_edits(&replaced);let inserted: Vec<Inserted> = texts@@ -91,7 +92,10 @@ impl Workbench {let transforms = session.transform_edits(&editor.document().lines, editor.document().indentation);let change = match transforms.is_empty() {true => None,- false => editor.execute_edits(transforms.into_iter().map(|(start, end, text)| (start, end, text, false)).collect(), None, EditReason::Unknown("snippet")),+ false => {+ let pairs = self.languages.rules(&editor.document().language_id).map(|rules| rules.auto_closing_pairs.as_slice()).unwrap_or_default();+ editor.execute_edits_tracking_pairs(transforms.into_iter().map(|(start, end, text)| (start, end, text, false)).collect(), None, EditReason::Unknown("snippet"), pairs)+ }};let session = editor.snippet_session.as_mut().expect("checked above");let selections = session.move_to(forward);diff --git a/port/ledger.md b/port/ledger.mdindex b24a74c7f2e..c465f8e2724 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -286,7 +286,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| 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 | | getWorkspaceIdentifier and getSingleFolderWorkspaceIdentifier (session.rs, workspaces.test.ts stable id case, cargo test -p exthost); recently opened list (recently_opened.rs, workspacesHistoryMainService: `history.recentlyOpenedPathsList` in shared storage, 500 per kind, cargo test -p app recently_opened); untitled workspaces under `<user data>/Workspaces/<id>/workspace.json` (config/src/workspace.rs isUntitledWorkspace, workbench/workspace_editing.rs createUntitledWorkspace, deleteUntitledWorkspace, Save Workspace As with rewritten relative paths): cargo test -p config workspace:: 5/5, cargo test -p app workspace_editing; ui-pair port/fixtures/ui-pair/m12/workspace-folders.json (Remove Folder from Workspace enters Untitled (Workspace)), verified at port-m12b-verify; getWorkspaceIdentifier and getSingleFolderWorkspaceIdentifier (session.rs, workspaces.test.ts stable id case, cargo test -p exthost); no untitled workspaces or recent list; getWorkspaceIdentifier and getSingleFolderWorkspaceIdentifier (session.rs, workspaces.test.ts stable id case, cargo test -p exthost); recently opened list (recently_opened.rs, workspacesHistoryMainService: `history.recentlyOpenedPathsList` in shared storage, 500 per kind, cargo test -p app recently_opened); no untitled workspaces; getWorkspaceIdentifier and getSingleFolderWorkspaceIdentifier (session.rs, workspaces.test.ts stable id case, cargo test -p exthost); no untitled workspaces or recent list || editor/browser | src/vs/editor | M8 | ported | [3 S] word_wrap.rs:157: an inlay hint with `editor.inlayHints.padding` broken by word wrap draws one padding box around both pieces, upstream's split spans each draw their own <br> [scheduling L] minimap.rs:87; minimap_view.rs:432; unicode_highlight.rs:63; indentation.rs:43; comment.rs:45; smart_select.rs:292: sticky minimap sampling, worker section headers and unicode highlights, tokenizeIfCheap, the 30 ms smart select yield. Accepted as "Scheduling differences" only with a measured same result and typing on a 50k-line TS file under 16 ms per edit; otherwise class 3. Audit inputs at 5e5b1b0a915. | scrolling: wheel, scrollbars with drag, track press and fade, scroll shadow, reveal on cursor moves and from the API, per-editor scroll position (editor/view.rs, workbench/editor_view.rs): cargo test -p app editor::view::tests (8); folding (editor/folding.rs): cargo test -p app editor::folding (49); minimap with slider, decorations, section headers, settings and the scrollbar context menu (editor/minimap.rs, editor/section_headers.rs, workbench/minimap_view.rs): cargo test -p app minimap (11), section_headers (18), editor_menus (8); sticky scroll (editor/contrib/stickyScroll row); rounded selections (`editor.roundedSelection`): cargo test -p app selection_corners (1); `editor.renderWhitespace` (editor/whitespace.rs): cargo test -p app whitespace (39); control characters and bidi format characters as `[U+XXXX]` (workbench/control_characters.rs): cargo test -p app control_characters (4); glyph margin and line number presses (workbench/gutter_mouse.rs): cargo test -p app gutter_presses (1); word wrap with view lines, Toggle Word Wrap and the wrap indicator (editor/word_wrap.rs): cargo test -p app word_wrap (21), ui-pair /tmp/m8wrap wrap.ts; `editor.smoothScrolling` (editor/smooth_scroll.rs, workbench/smooth_scrolling.rs): cargo test -p app smooth_scroll (11, the scrollable.test.ts cases); diff editor widget (port/notes.md milestone 14): cargo test -p app diff_editor (22), diff_gutter (2); all run at the milestone 20 sweep; scrolling: wheel, scrollbars with drag, track press and fade, scroll shadow, reveal on cursor moves and from the API, per-editor scroll position (editor/view.rs, workbench/editor_view.rs): cargo test -p app editor::view::tests; folding (editor/folding.rs): cargo test -p app editor::folding; minimap with slider, decorations and section headers (editor/minimap.rs, editor/section_headers.rs, workbench/minimap_view.rs): cargo test -p app minimap, cargo test -p app section_headers; sticky scroll (editor/contrib/stickyScroll row); rounded selections (`editor.roundedSelection`, selections.ts): cargo test -p app selection_corners, ui-pair corners match; `editor.renderWhitespace` marks drawn as svg circles and arrows (editor/whitespace.rs, viewParts/whitespace): cargo test -p app whitespace, ui-pair notes.txt; control characters as Control Pictures (`editor.renderControlCharacters`, workbench/control_characters.rs): cargo test -p app control_characters; glyph margin and line number presses select lines, drags extend them, Alt adds a line cursor (mouseHandler.ts `startedOnLineNumbers`, workbench/gutter_mouse.rs): cargo test -p app gutter_presses; no smooth scrolling, no word wrap (`editor.wordWrap`, viewModelLines with line breaks), bidi format characters not drawn as `[U+XXXX]` (port/notes.md milestone 8); diff editor widget (side by side, inline, view zones, gutter toolbar, overview ruler, title actions; port/notes.md milestone 14): cargo test -p app diff_editor diff_gutter; Switch Side (`diffEditor.switchSide`, the selection mapped through the diff) and Focus Primary, Secondary and Other Side, in the diff and the multi diff editor: cargo test -p app switch_side; bracket pair guides (`editor.guides.bracketPairs`, `bracketPairsHorizontal`, `highlightActiveBracketPair`; guidesTextModelPart.ts) in every code editor, on a wrapped line only on the view lines `getViewLinesBracketGuides` keeps (viewModelLines.ts): cargo test -p app bracket_pair_guide; indent guides on a wrapped line repeated on its view lines only with a wrapping indent (`getViewLinesIndentGuides`, viewModelLines.ts), none past the wrapping column (`_maxIndentLeft`, indentGuides.ts): cargo test -p app wrapping_indent_repeats without_a_wrapping_indent; scrolling: wheel, scrollbars with drag, track press and fade, scroll shadow, reveal on cursor moves and from the API, per-editor scroll position (editor/view.rs, workbench/editor_view.rs): cargo test -p app editor::view::tests; folding (editor/folding.rs): cargo test -p app editor::folding; minimap with slider, decorations and section headers (editor/minimap.rs, editor/section_headers.rs, workbench/minimap_view.rs): cargo test -p app minimap, cargo test -p app section_headers; sticky scroll (editor/contrib/stickyScroll row); rounded selections (`editor.roundedSelection`, selections.ts): cargo test -p app selection_corners, ui-pair corners match; no `renderWhitespace` yet; no smooth scrolling (port/notes.md milestone 8); scrolling: wheel, scrollbars with drag, track press and fade, scroll shadow, reveal on cursor moves and from the API, per-editor scroll position (editor/view.rs, workbench/editor_view.rs): cargo test -p app editor::view::tests; folding (editor/folding.rs): cargo test -p app editor::folding; minimap with slider, decorations and section headers (editor/minimap.rs, editor/section_headers.rs, workbench/minimap_view.rs): cargo test -p app minimap, cargo test -p app section_headers; sticky scroll (editor/contrib/stickyScroll row); rounded selections (`editor.roundedSelection`, selections.ts): cargo test -p app selection_corners, ui-pair corners match; `editor.renderWhitespace` marks drawn as svg circles and arrows (editor/whitespace.rs, viewParts/whitespace): cargo test -p app whitespace, ui-pair notes.txt; control characters as Control Pictures (`editor.renderControlCharacters`, workbench/control_characters.rs): cargo test -p app control_characters; glyph margin and line number presses select lines, drags extend them, Alt adds a line cursor (mouseHandler.ts `startedOnLineNumbers`, workbench/gutter_mouse.rs): cargo test -p app gutter_presses; word wrap with view lines, Toggle Word Wrap and the wrap indicator (editor/word_wrap.rs: cargo test -p app word_wrap; ui-pair /tmp/m8wrap wrap.ts: breaks, End, Down and Alt+Z match the reference); bidi format characters as `[U+XXXX]` (cargo test -p app control_characters); minimap settings and the scrollbar context menu (cargo test -p app minimap editor_menus); `editor.smoothScrolling` over 125 ms for cursor, find and API reveals and mouse wheel notches (editor/smooth_scroll.rs, workbench/smooth_scrolling.rs: cargo test -p app smooth_scroll, the scrollable.test.ts cases); diff editor widget (side by side, inline, view zones, gutter toolbar, overview ruler, title actions; port/notes.md milestone 14): cargo test -p app diff_editor diff_gutter; each side its own editor (the original's cursor and active line number, inline only its line numbers wide), char changes filled past the line break (`shouldFillLineOnLineBreak`) but not in the inline deleted lines, the sides' overview ruler without the minimap background, a press with no move before it shows the scrollbars: cargo test -p app file_compare char_ranges a_click_without_a_move, ui-pair m12/compare.json; mouse selection: four clicks select all, a double click the word (`WordOperations.word`) or the inside of brackets and strings (`editor.doubleClickSelectsBlock`), double and triple click drags go on by words and lines, their Alt forms on the cursor added last, a drag past the text scrolls each frame (dragScrolling.ts) (editor/mouse_selection.rs, workbench/drag_scrolling.rs): cargo test -p app mouse_selection text_clicks_select a_selecting_drag_below (6), in the vertical scrollbar without the minimap, below the horizontal scrollbar's top and in a comment reply editor: cargo test -p app a_drag_into_the_vertical the_bottom_edge_hit a_drag_below_a_comment; the IME input handler sees the selection's lines, a caret inside marked text places the cursor and character bounds follow the text (nativeEditContext.ts): cargo test -p app text_input::; decoration type outlines outside the range and borders inside it, the CSS cascade of their shorthands and longhands, `before`/`after` content text as injected text (workbench/editor_view/text_decorations.rs): cargo test -p app outline_and_border_follow_the_css_cascade a_decoration_outline_is_drawn_outside_its_range decoration_types_set_and_remove_editor_decorations, ui-pair of a merge conflict file: the header's "(Incoming Change)" text matches the reference |-| editor/common | src/vs/editor | M8 | ported | [3 M] edit.rs:882: a pair a snippet or suggestion inserts is not tracked as auto-closed, so typing does not overtype its close (cursor.ts `executeEdits` `_findAutoClosingPairs`; cursor.test.ts issues #78975, #315131) <br> [scheduling L] minimap.rs:87; minimap_view.rs:432; unicode_highlight.rs:63; indentation.rs:43; comment.rs:45; smart_select.rs:292: sticky minimap sampling, worker section headers and unicode highlights, tokenizeIfCheap, the 30 ms smart select yield. Accepted as "Scheduling differences" only with a measured same result and typing on a 50k-line TS file under 16 ms per edit; otherwise class 3. Audit inputs at 5e5b1b0a915. | the model and cursor layer under every editor (app/src/editor, decorations.rs, link_computer.rs, syntax.rs, the diff crate): cursors (CursorCollection normalize, per-cursor edits, loser edits, paste distribution, column selection), core moves and deletes over grapheme clusters, word operations, the edit stack with its stops and the alternative version id dirty state, onEnter and indentation rules (`languages/autoIndent.ts`, `enterAction.ts`, EnterOperation, electric characters, TabOperation, ShiftCommand miss-aligned lines), auto-closing of typed brackets and quotes (`AutoClosingOpenCharTypeOperation`, `hasUnmatchedClosingBracketAfter`: cargo test -p app auto_closing), indentation guessing, model decorations with injected text, bracket matching and bracket pair colorization over the incremental bracket tree (bracketPairsTree/, brackets/tree.rs: cargo test -p app brackets; typing on the 52k-line TS file 1.40, 1.73, 2.29 ms median per edit: cargo test --release -p app -- --ignored typing_latency_on_a_large_file), the lines in view past the tokenized ones tokenized from a guessed start state (`tokenizeHeuristically`: cargo test -p app lines_in_view_past_the_tokenized_ones), the link computer, view lines with word wrap: cargo test -p app editor:: decorations:: link_computer syntax:: (781 passed, 13 ignored: the upstream `test.skip` cases of indentation.test.ts); the diff algorithms of editor/common/diff: cargo test -p diff (15 passed). `getWordAtPosition` inside the token language with its `wordPattern`: cargo test -p app the_word_at_a_column (model.test.ts 'Get word at position', 'getWordAtPosition at embedded language boundaries', 'issue #61296'). Swapped by design: the piece tree text buffer is a vector of lines (no observable difference; large files go through workbench/large_file.rs). Gap (editor audit): pushEOL not on the undo stack (edit.rs). Full-width chars take two visible columns for tab stops and cursor moves and draw at the font's full-width advance: cargo test -p app full_width_chars_take moving_down_keeps. Language configuration regexes read a class hyphen next to `\w`, `\d` or `\s` as JavaScript does (css `[\w-?]`, folding.rs `marker_regex`): cargo test -p app a_hyphen_next_to_a_class_escape_is_literal. |+| editor/common | src/vs/editor | M8 | ported | [scheduling L] minimap.rs:87; minimap_view.rs:432; unicode_highlight.rs:63; indentation.rs:43; comment.rs:45; smart_select.rs:292: sticky minimap sampling, worker section headers and unicode highlights, tokenizeIfCheap, the 30 ms smart select yield. Accepted as "Scheduling differences" only with a measured same result and typing on a 50k-line TS file under 16 ms per edit; otherwise class 3. Audit inputs at 5e5b1b0a915. | the model and cursor layer under every editor (app/src/editor, decorations.rs, link_computer.rs, syntax.rs, the diff crate): cursors (CursorCollection normalize, per-cursor edits, loser edits, paste distribution, column selection), core moves and deletes over grapheme clusters, word operations, the edit stack with its stops and the alternative version id dirty state, onEnter and indentation rules (`languages/autoIndent.ts`, `enterAction.ts`, EnterOperation, electric characters, TabOperation, ShiftCommand miss-aligned lines), auto-closing of typed brackets and quotes (`AutoClosingOpenCharTypeOperation`, `hasUnmatchedClosingBracketAfter`: cargo test -p app auto_closing), indentation guessing, model decorations with injected text, bracket matching and bracket pair colorization over the incremental bracket tree (bracketPairsTree/, brackets/tree.rs: cargo test -p app brackets; typing on the 52k-line TS file 1.40, 1.73, 2.29 ms median per edit: cargo test --release -p app -- --ignored typing_latency_on_a_large_file), the lines in view past the tokenized ones tokenized from a guessed start state (`tokenizeHeuristically`: cargo test -p app lines_in_view_past_the_tokenized_ones), the link computer, view lines with word wrap: cargo test -p app editor:: decorations:: link_computer syntax:: (781 passed, 13 ignored: the upstream `test.skip` cases of indentation.test.ts); the diff algorithms of editor/common/diff: cargo test -p diff (15 passed). `getWordAtPosition` inside the token language with its `wordPattern`: cargo test -p app the_word_at_a_column (model.test.ts 'Get word at position', 'getWordAtPosition at embedded language boundaries', 'issue #61296'). Swapped by design: the piece tree text buffer is a vector of lines (no observable difference; large files go through workbench/large_file.rs). Gap (editor audit): pushEOL not on the undo stack (edit.rs). Full-width chars take two visible columns for tab stops and cursor moves and draw at the font's full-width advance: cargo test -p app full_width_chars_take moving_down_keeps. Language configuration regexes read a class hyphen next to `\w`, `\d` or `\s` as JavaScript does (css `[\w-?]`, folding.rs `marker_regex`): cargo test -p app a_hyphen_next_to_a_class_escape_is_literal. || 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 || editor/contrib/anchorSelect | src/vs/editor/contrib | M8 | verified | | `editor/anchor_select.rs`: the four commands with their keys and `selectionAnchorSet`, the anchor moved by edits as a `NeverGrowsWhenTypingAtEdges` marker, the bar under the word highlights: cargo test -p app anchor; ui-pair notes.txt through the Command Palette; no hover message until editor hovers |diff --git a/port/notes.md b/port/notes.mdindex 4124cb4c067..3604870181f 100644--- a/port/notes.md+++ b/port/notes.md@@ -481,7 +481,7 @@ Done when (first item): api-tests `vscode API - editors` passes as in the refere- Go to Line/Column and Go to Offset (`workbench/quick_access/goto_line.rs`, gotoLineQuickAccess.ts over editorNavigationQuickAccess.ts): `workbench.action.gotoLine` (Ctrl+G) and `workbench.action.gotoOffset` show quick access with `:` and `::`, both in the Command Palette. `parsePosition` with `line`, `line:col`, `line,col`, `line#col`, negative values from the end, visible columns over tabs, UTF-16 offsets, and the zero-based offset toggle (`index-zero` input button, `gotoLine.useZeroBasedOffset` in application storage). While the value changes the line is revealed in the center with `rangeHighlight` and a full-lane `editorOverviewRuler.rangeHighlightForeground` mark; Enter moves the cursor there (`code.jump`) and focuses the editor, accept in background keeps the picker, Escape or another prefix restores the view state. With `editor.lineNumbers` `relative` the editor numbers as `on` while the picker previews in it. Not ported: Alt or Cmd accept opening to the side (no editor groups), the aria status. Tests: `cargo test -p app go_to_line positions_parse`.- `editor.lineNumbers` `relative` and `interval` render as lineNumbers.ts `_getLineRenderLineNumber`: distances from the primary cursor with its own line number left-aligned (`.relative-current-line-number`), or every tenth line, the cursor's and the last (`cargo test -p app line_numbers`). `renderFinalNewline` is not applied to the number of an empty last line.- Auto-indent (`editor/auto_indent.rs`, `languages/autoIndent.ts`, `enterAction.ts`, `cursorTypeEditOperations.ts`): `Languages::configure` parses `onEnterRules` and `indentationRules` beside the brackets; `Model` is upstream's virtual model over a document with one line replaced. Enter runs `EnterOperation._enter` (strategy none: plain newline; keep, or a line not cheap to tokenize: copy the indentation; else `getEnterAction` and `getIndentForEnter`), typing runs `AutoIndentOperation` then the electric closing bracket (`getIndentActionForType`, strategy full only), Tab on a blank line `TabOperation._goodIndentForLine`, Shift/Tab over lines `ShiftCommand` with its miss-aligned line heuristic (JSDoc ` * ` is not indentation). Insert Line Above/Below and Move Line Up/Down use the same rules. `editor.action.reindentlines` and `reindentselectedlines` (palette only, as upstream) run `getReindentEditOperations`. This replaces the milestone 5 shortcut "Enter copies the leading whitespace only". Not ported: auto-indent on paste (`editor.autoIndentOnPaste`, default off). Tests: `cargo test -p app editor::auto_indent` (cursor.test.ts indent cases, indentation.test.ts Auto Indent On Type - TypeScript/JavaScript, shiftCommand.test.ts issues #348 and #1609). ui-pair on a `.ts` file: Enter after `{` and after `/** a` gives the reference's text (` x`, ` * b`).-- Auto-closing on type (`editor/auto_closing.rs`; cursorTypeEditOperations.ts `AutoClosingOvertypeOperation`, `AutoClosingOpenCharTypeOperation`, `TypeWithAutoClosingCommand`, `SurroundSelectionOperation`, cursor.ts `AutoClosedAction`): `typeWithInterceptors` runs AutoIndent (which auto-closes too), then the overtype of a close char, then the open char, then the surround of every selection, then the electric char. `editor.autoClosingOvertype` `auto` types over only a close char the editor auto-closed, `always` over any, never a quote after a backslash; `editor.autoClosingDelete` the same for Delete Left and Delete Word Left. `editor.autoSurround` wraps selections in the language's `surroundingPairs`, else its auto-closing pairs. The pairs are the language's `autoClosingPairs` (else its brackets) with `notIn`, `beforeText` and `autoCloseBefore`; `editor.autoClosingBrackets`, `autoClosingQuotes`, `autoClosingComments` and `wordSeparators` come from the editor's language. A typed multi-char open (`begin`) gets an undo stop before its close, so undo first removes the close. Each editor keeps its auto-closed ranges as edit-tracked positions that never grow, dropped once a cursor leaves them. No composition (`chIsAlreadyTyped`) path and no reentrant content listeners, so cursor.test.ts's composition and reentrant-edit cases are not ported. Pairs inserted by snippets or suggestions are not tracked yet (ledger gap). Tests: `cargo test -p app auto_closing` (cursor.test.ts autoClosingPairs open, quote, multi-character, beforeText, auto wrapping, issues #6841, #11476, #25658, #27937, #37315, #41825, #47733, #53357, #78527, #118270, all cursors deleting left, #55314, #61070, #72177, #78833, #84998, #132912, #206774, #338693).+- Auto-closing on type (`editor/auto_closing.rs`; cursorTypeEditOperations.ts `AutoClosingOvertypeOperation`, `AutoClosingOpenCharTypeOperation`, `TypeWithAutoClosingCommand`, `SurroundSelectionOperation`, cursor.ts `AutoClosedAction`): `typeWithInterceptors` runs AutoIndent (which auto-closes too), then the overtype of a close char, then the open char, then the surround of every selection, then the electric char. `editor.autoClosingOvertype` `auto` types over only a close char the editor auto-closed, `always` over any, never a quote after a backslash; `editor.autoClosingDelete` the same for Delete Left and Delete Word Left. `editor.autoSurround` wraps selections in the language's `surroundingPairs`, else its auto-closing pairs. The pairs are the language's `autoClosingPairs` (else its brackets) with `notIn`, `beforeText` and `autoCloseBefore`; `editor.autoClosingBrackets`, `autoClosingQuotes`, `autoClosingComments` and `wordSeparators` come from the editor's language. A typed multi-char open (`begin`) gets an undo stop before its close, so undo first removes the close. Each editor keeps its auto-closed ranges as edit-tracked positions that never grow, dropped once a cursor leaves them. No composition (`chIsAlreadyTyped`) path and no reentrant content listeners, so cursor.test.ts's composition and reentrant-edit cases are not ported. Snippet and suggestion edits go through `execute_edits_tracking_pairs` (cursor.ts `executeEdits` with `_findAutoClosingPairs`), so their pairs are auto-closed too. Tests: `cargo test -p app auto_closing` (cursor.test.ts autoClosingPairs open, quote, multi-character, beforeText, auto wrapping, issues #6841, #11476, #25658, #27937, #37315, #41825, #47733, #53357, #78527, #78975, #118270, #315131, all cursors deleting left, #55314, #61070, #72177, #78833, #84998, #132912, #206774, #338693).- Smart select (`editor/smart_select.rs`, smartSelect.ts, wordSelections.ts, bracketSelections.ts): `OpenEditor::smart_select` keeps each cursor's ranges while the selections are the ones it set; the bracket ranges come from `Tokenization::pairs` (`DocumentBrackets.brackets`), words use the language's `wordPattern` (`LanguageRules::word_pattern`), else `word_at`. ui-pair on `foo(barBaz)` in a .ts file (Ctrl+Shift+Right 3 times, Ctrl+Shift+Left once): shrink matches the reference; the third expand gives `(barBaz)` where the reference, with the TypeScript extension's provider, gives `foo(barBaz)`. After the shrink the port draws the word highlight over the selected `barBaz`, the reference shows the plain selection color. In plain text both draw the highlight over the selected word (ui-pair on notes.txt), so the .ts difference is the TypeScript extension's document highlight provider; the port has only the textual one.- Word highlights follow `wordHighlighter.ts` `_run`: the word at the selection start, none when the selection reaches past it (`refresh_highlights`). The highlight paints above the selection as `DecorationsOverlay` sits above `SelectionsOverlay` (view.ts). Test: `cargo test -p app the_cursor_highlights_its_word`.- Word parts (`wordPartOperations.ts`, `cursorWordOperations.ts` `_moveWordPartLeft/Right`, `deleteWordPartLeft/Right`): the nearest of the word start, word end and camelCase/snake_case/kebab-case boundary; deletes take upstream's range comparators. Keys Ctrl+Alt+Left/Right (Shift selects), Ctrl+Alt+Backspace/Delete. Test: `cargo test -p app word_part` with the cases of `wordPartOperations.test.ts`.