Visual Studio Code, rebuilt in Rust
Rust
feat(editor): overtype auto-closed brackets and quotes
rokartur2d23856785f3
diff --git a/native/crates/app/src/editor/auto_closing.rs b/native/crates/app/src/editor/auto_closing.rsindex fcd725d120f..38ba994a7df 100644--- a/native/crates/app/src/editor/auto_closing.rs+++ b/native/crates/app/src/editor/auto_closing.rs@@ -53,12 +53,14 @@ pub struct Options<'a> {pub brackets: AutoClose,pub quotes: AutoClose,pub comments: AutoClose,+ /// `editor.autoClosingOvertype`: "always", "auto" or "never".+ pub overtype: &'a str,pub word_separators: &'a str,}impl Default for Options<'_> {fn default() -> Self {- Options { brackets: AutoClose::LanguageDefined, quotes: AutoClose::LanguageDefined, comments: AutoClose::LanguageDefined, word_separators: DEFAULT_WORD_SEPARATORS }+ Options { brackets: AutoClose::LanguageDefined, quotes: AutoClose::LanguageDefined, comments: AutoClose::LanguageDefined, overtype: "auto", word_separators: DEFAULT_WORD_SEPARATORS }}}@@ -167,6 +169,39 @@ impl AutoClosedAction {}impl OpenEditor {+ /// `AutoClosingOvertypeOperation`: typing the close char that sits after every empty cursor types over it.+ pub(super) fn auto_closing_overtype(&mut self, ch: char, auto: AutoIndent) -> Option<Vec<ContentChanged>> {+ if !self.is_auto_closing_overtype(ch, auto) {+ return None;+ }+ let ranges = self.selections.iter().map(|selection| (selection.head, Position::new(selection.head.line, selection.head.column + 1))).collect();+ Some(self.type_into(&ch.to_string(), ranges, "type").into_iter().collect())+ }++ /// `isAutoClosingOvertype`.+ fn is_auto_closing_overtype(&self, ch: char, auto: AutoIndent) -> bool {+ let overtype = auto.closing.overtype;+ if overtype == "never" {+ return false;+ }+ let document = self.document();+ let Some(rules) = auto.languages.rules(&document.language_id) else { return false };+ let closes_single_char = |pair: &Pair| pair.open.chars().count() == 1 && pair.close.chars().eq([ch]);+ if !rules.character_pairs.pairs.iter().any(closes_single_char) {+ return false;+ }+ self.selections.iter().all(|selection| {+ let position = selection.head;+ let text: Vec<char> = document.lines[position.line].chars().collect();+ // `beforeCharacter` is read only from upstream's 1-based column 3 on.+ let after_backslash = position.column > 1 && text[position.column - 1] == '\\';+ selection.is_empty()+ && text.get(position.column) == Some(&ch)+ && !(after_backslash && is_quote(ch))+ && (overtype != "auto" || self.auto_closed.iter().any(|action| action.characters.iter().any(|&(start, _)| start == position)))+ })+ }+/// `AutoClosingOpenCharTypeOperation`: typing the last char of an auto-closing pair's open at every cursor also/// inserts the close after it.pub(super) fn auto_closing_open_type(&mut self, ch: char, auto: AutoIndent) -> Option<Vec<ContentChanged>> {diff --git a/native/crates/app/src/editor/auto_closing/tests.rs b/native/crates/app/src/editor/auto_closing/tests.rsindex 8ebdcaa3192..a46f8bbd4f0 100644--- a/native/crates/app/src/editor/auto_closing/tests.rs+++ b/native/crates/app/src/editor/auto_closing/tests.rs@@ -57,6 +57,11 @@ impl Cursor {self}+ fn overtype(mut self, overtype: &'static str) -> Self {+ self.options.overtype = overtype;+ self+ }+/// `setupAutoClosingLanguageTokenization`: strings, comments and `${}` in strings tokenized by grammar.json.fn tokenized(mut self) -> Self {let folder = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/editor/auto_closing");@@ -412,3 +417,97 @@ fn issue_25658_do_not_auto_close_quotes_after_word_characters() {assert_eq!(cursor.line(line + 1), expected);}}++#[test]+fn issue_37315_overtypes_only_those_characters_that_it_inserted() {+ let mut cursor = Cursor::new(auto_closing_language(), &["", "y=();"]);+ cursor.type_text("x=(");+ assert_eq!(cursor.line(1), "x=()");+ cursor.type_text("asd");+ assert_eq!(cursor.line(1), "x=(asd)");+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=(asd)", "overtype");+ cursor.select(&[(2, 4)]);+ cursor.type_text(")");+ assert_eq!(cursor.line(2), "y=());", "do not overtype");+}++#[test]+fn issue_37315_stops_overtyping_once_cursor_leaves_area() {+ let mut cursor = Cursor::new(auto_closing_language(), &["", "y=();"]);+ cursor.type_text("x=(");+ assert_eq!(cursor.line(1), "x=()");+ cursor.select(&[(1, 5)]);+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=())");+}++#[test]+fn issue_37315_it_overtypes_only_once() {+ let mut cursor = Cursor::new(auto_closing_language(), &["", "y=();"]);+ cursor.type_text("x=(");+ assert_eq!(cursor.line(1), "x=()");+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=()");+ cursor.select(&[(1, 4)]);+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=())");+}++#[test]+fn issue_37315_it_can_remember_multiple_auto_closed_instances() {+ let mut cursor = Cursor::new(auto_closing_language(), &["", "y=();"]);+ cursor.type_text("x=(");+ assert_eq!(cursor.line(1), "x=()");+ cursor.type_text("(");+ assert_eq!(cursor.line(1), "x=(())");+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=(())");+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=(())");+}++#[test]+fn issue_78833_add_config_to_use_old_brackets_quotes_overtyping() {+ let mut cursor = Cursor::new(auto_closing_language(), &["", "y=();"]).overtype("always");+ cursor.type_text("x=(");+ assert_eq!(cursor.line(1), "x=()");+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=()");+ cursor.select(&[(1, 4)]);+ cursor.type_text(")");+ assert_eq!(cursor.line(1), "x=()");+ cursor.select(&[(2, 4)]);+ cursor.type_text(")");+ assert_eq!(cursor.line(2), "y=();");+}++#[test]+fn issue_53357_over_typing_ignores_characters_after_backslash() {+ let mut cursor = Cursor::new(auto_closing_language(), &["console.log();"]);+ cursor.select(&[(1, 13)]);+ cursor.type_text("'");+ assert_eq!(cursor.value(), "console.log('');");+ cursor.type_text("it");+ assert_eq!(cursor.value(), "console.log('it');");+ cursor.type_text("\\");+ assert_eq!(cursor.value(), "console.log('it\\');");+ cursor.type_text("'");+ assert_eq!(cursor.value(), "console.log('it\\'');");+}++#[test]+fn issue_84998_overtyping_brackets_does_not_work_after_backslash() {+ let mut cursor = Cursor::new(auto_closing_language(), &[""]);+ cursor.select(&[(1, 1)]);+ cursor.type_text("\\");+ assert_eq!(cursor.value(), "\\");+ cursor.type_text("(");+ assert_eq!(cursor.value(), "\\()");+ cursor.type_text("abc");+ assert_eq!(cursor.value(), "\\(abc)");+ cursor.type_text("\\");+ assert_eq!(cursor.value(), "\\(abc\\)");+ cursor.type_text(")");+ assert_eq!(cursor.value(), "\\(abc\\)");+}diff --git a/native/crates/app/src/editor/edit.rs b/native/crates/app/src/editor/edit.rsindex 6c73bcc6b1d..536318b9fd7 100644--- a/native/crates/app/src/editor/edit.rs+++ b/native/crates/app/src/editor/edit.rs@@ -452,7 +452,7 @@ impl OpenEditor {}/// The typed text replaces `ranges`, one per selection; spaces and other text group into undo steps as upstream does.- fn type_into(&mut self, text: &str, ranges: Vec<(Position, Position)>, kind: &'static str) -> Option<ContentChanged> {+ pub(super) fn type_into(&mut self, text: &str, ranges: Vec<(Position, Position)>, kind: &'static str) -> Option<ContentChanged> {let text = normalize_line_breaks(text);let last_kind = self.text_model().history.last_kind;let typing = match text.as_str() {@@ -481,7 +481,7 @@ impl OpenEditor {if ch == '\n' {return self.enter(auto).into_iter().collect();}- if let Some(changes) = self.auto_indent_type(ch, auto).or_else(|| self.auto_closing_open_type(ch, auto)) {+ if let Some(changes) = self.auto_indent_type(ch, auto).or_else(|| self.auto_closing_overtype(ch, auto)).or_else(|| self.auto_closing_open_type(ch, auto)) {return changes;}let text = ch.to_string();diff --git a/native/crates/app/src/workbench/editor_commands.rs b/native/crates/app/src/workbench/editor_commands.rsindex 634f32db7e9..10fb1bf79ae 100644--- a/native/crates/app/src/workbench/editor_commands.rs+++ b/native/crates/app/src/workbench/editor_commands.rs@@ -565,7 +565,8 @@ impl Workbench {let strategy = Strategy::from_setting(setting("editor.autoIndent").as_ref());let word_separators = setting("editor.wordSeparators").and_then(|value| value.as_str().map(str::to_string)).unwrap_or(word_operations::DEFAULT_WORD_SEPARATORS.to_string());let (brackets, quotes, comments) = (setting("editor.autoClosingBrackets"), setting("editor.autoClosingQuotes"), setting("editor.autoClosingComments"));- let closing = auto_closing::Options { brackets: AutoClose::from_setting(brackets.as_ref()), quotes: AutoClose::from_setting(quotes.as_ref()), comments: AutoClose::from_setting(comments.as_ref()), word_separators: &word_separators };+ let overtype = setting("editor.autoClosingOvertype").and_then(|value| value.as_str().map(str::to_string)).unwrap_or("auto".to_string());+ let closing = auto_closing::Options { brackets: AutoClose::from_setting(brackets.as_ref()), quotes: AutoClose::from_setting(quotes.as_ref()), comments: AutoClose::from_setting(comments.as_ref()), overtype: &overtype, word_separators: &word_separators };drop(settings);let selections_before = editor.selections.clone();drop(document);diff --git a/port/ledger.md b/port/ledger.mdindex 6e4e0c96ef8..154fb5e6deb 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 L] edit.rs:480: typing does not overtype the auto-closed brackets and quotes or surround a selection, and Delete Left does not delete an auto-closed pair (`typeWithInterceptors` AutoClosingOvertype, SurroundSelection in cursorTypeEditOperations.ts; cursor.test.ts autoClosing overtype, surround and delete cases) <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 | [3 L] edit.rs:480: typing does not surround a selection, and Delete Left does not delete an auto-closed pair (`typeWithInterceptors` SurroundSelection in cursorTypeEditOperations.ts; cursor.test.ts surround and delete cases) <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/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 c3e7c27c5ab..50f4b01a60c 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 `AutoClosingOpenCharTypeOperation`, `TypeWithAutoClosingCommand`, cursor.ts `AutoClosedAction`): `typeWithInterceptors` runs AutoIndent (which auto-closes too), then the open char, then the electric char. 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. Tests: `cargo test -p app auto_closing` (cursor.test.ts autoClosingPairs open, quote, multi-character, beforeText, issues #6841, #25658, #27937, #55314, #61070, #72177, #132912, #338693).+- Auto-closing on type (`editor/auto_closing.rs`; cursorTypeEditOperations.ts `AutoClosingOvertypeOperation`, `AutoClosingOpenCharTypeOperation`, `TypeWithAutoClosingCommand`, cursor.ts `AutoClosedAction`): `typeWithInterceptors` runs AutoIndent (which auto-closes too), then the overtype of a close char, then the open char, 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. 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. Tests: `cargo test -p app auto_closing` (cursor.test.ts autoClosingPairs open, quote, multi-character, beforeText, issues #6841, #25658, #27937, #37315, #53357, #55314, #61070, #72177, #78833, #84998, #132912, #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`.