Visual Studio Code, rebuilt in Rust
Rust
feat(editor): delete auto-closed pairs with Delete Left
rokartur01e6da76a198
diff --git a/native/crates/app/src/editor/auto_closing.rs b/native/crates/app/src/editor/auto_closing.rsindex 6eb25c5e7bb..72e21960913 100644--- a/native/crates/app/src/editor/auto_closing.rs+++ b/native/crates/app/src/editor/auto_closing.rs@@ -376,6 +376,11 @@ impl OpenEditor {Some(close.clone())}+ /// `getAutoClosedCharacters`: where each auto-closed char starts.+ pub(super) fn auto_closed_characters(&self) -> Vec<Position> {+ self.auto_closed.iter().flat_map(|action| action.characters.iter().map(|&(start, _)| start)).collect()+ }+/// `_validateAutoClosedActions`, after every cursor change.pub(super) fn validate_auto_closed(&mut self) {let mut selections: Vec<_> = self.selections.iter().map(|selection| (selection.start(), selection.end())).collect();diff --git a/native/crates/app/src/editor/auto_closing/tests.rs b/native/crates/app/src/editor/auto_closing/tests.rsindex 9f9cac2b82f..ca2e2def8cd 100644--- a/native/crates/app/src/editor/auto_closing/tests.rs+++ b/native/crates/app/src/editor/auto_closing/tests.rs@@ -6,6 +6,7 @@ use super::*;use crate::editor::auto_indent::Strategy;use crate::editor::cursor::Selection;use crate::editor::edit::tests::editor;+use crate::editor::word_operations::{AutoClosing, DELETE_COMMANDS, NO_AUTO_CLOSING};use crate::languages::Languages;use crate::syntax::Tokenization;@@ -97,6 +98,18 @@ impl Cursor {self.editor.type_keyboard(text, auto, false);}+ /// `CoreEditingCommands.DeleteLeft`, or with `word` `DeleteWordLeft`, with the language's pairs.+ fn delete_left(&mut self, word: bool) {+ let pairs = self.languages.rules("testLanguage").map(|rules| rules.auto_closing_pairs.clone()).unwrap_or_default();+ let auto_closing = AutoClosing { pairs: &pairs, ..NO_AUTO_CLOSING };+ if !word {+ self.editor.delete_left(&auto_closing);+ return;+ }+ let (id, word_delete) = DELETE_COMMANDS.into_iter().find(|(id, _)| *id == "deleteWordLeft").unwrap();+ self.editor.delete_word(&WordClassifier::new(DEFAULT_WORD_SEPARATORS, &[]), &auto_closing, word_delete, id);+ }+fn carets(&self) -> Vec<(usize, usize)> {self.editor.selections.iter().map(|selection| (selection.head.line + 1, selection.head.column + 1)).collect()}@@ -595,3 +608,51 @@ fn issue_41825_special_handling_of_quotes_in_surrounding_pairs() {cursor.type_text("'");assert_eq!(cursor.value(), "var x = 'hi';");}++#[test]+fn issue_118270_auto_closing_deletes_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)");+ for _ in 0..3 {+ cursor.delete_left(false);+ }+ assert_eq!(cursor.line(1), "x=()");+ cursor.delete_left(false);+ assert_eq!(cursor.line(1), "x=", "delete closing char");+ cursor.select(&[(2, 4)]);+ cursor.delete_left(false);+ assert_eq!(cursor.line(2), "y=);", "do not delete closing char");+}++#[test]+fn delete_word_left_deletes_an_auto_closed_pair() {+ let mut cursor = Cursor::new(auto_closing_language(), &["", "y=();"]);+ cursor.type_text("x=(");+ cursor.delete_left(true);+ assert_eq!(cursor.line(1), "x=");+ cursor.select(&[(2, 4)]);+ cursor.delete_left(true);+ assert_eq!(cursor.line(2), "y);", "deletes the word, not the pair it did not insert");+}++#[test]+fn all_cursors_should_do_the_same_thing_when_deleting_left() {+ let mut cursor = Cursor::new(auto_closing_language(), &["var a = ()"]);+ cursor.select(&[(1, 4), (1, 10)]);+ cursor.delete_left(false);+ assert_eq!(cursor.value(), "va a = )");+}++#[test]+fn issue_78527_does_not_close_quote_on_odd_count() {+ let mut cursor = Cursor::new(auto_closing_language(), &["std::cout << '\"' << entryMap"]);+ cursor.select(&[(1, 29)]);+ let steps = [("[", "std::cout << '\"' << entryMap[]"), ("\"", "std::cout << '\"' << entryMap[\"\"]"), ("a", "std::cout << '\"' << entryMap[\"a\"]"), ("\"", "std::cout << '\"' << entryMap[\"a\"]"), ("]", "std::cout << '\"' << entryMap[\"a\"]")];+ for (ch, expected) in steps {+ cursor.type_text(ch);+ assert_eq!(cursor.line(1), expected, "{ch}");+ }+}diff --git a/native/crates/app/src/editor/edit.rs b/native/crates/app/src/editor/edit.rsindex f494a4cacb6..574543fbf65 100644--- a/native/crates/app/src/editor/edit.rs+++ b/native/crates/app/src/editor/edit.rs@@ -554,7 +554,21 @@ impl OpenEditor {self.apply_cursor_edits(edits, command("lineBreakInsert"))}- pub fn delete_left(&mut self) -> Option<ContentChanged> {+ /// `deleteLeft`: with every cursor between an auto-closing pair's open and its close, both go.+ pub fn delete_left(&mut self, auto_closing: &AutoClosing) -> Option<ContentChanged> {+ let auto_closed = self.auto_closed_characters();+ let pair_delete = self.selections.iter().all(|&selection| word_operations::is_auto_closing_pair_delete(auto_closing, &auto_closed, &self.document().lines, selection));+ if pair_delete {+ let edits = self.each_cursor(|selection| {+ let head = selection.head;+ let open = Position::new(head.line, head.column - 1);+ CursorEdit::replace(open, Position::new(head.line, head.column + 1), String::new(), open)+ });+ self.push_undo_stop();+ let change = self.apply_cursor_edits(edits, command("deleteLeft"));+ self.text_model_mut().history.last_kind = EditKind::DeletingLeft;+ return change;+ }let indentation = self.document().indentation;self.delete(|lines, selection| cursor::delete_left_range(lines, selection, indentation), Some(EditKind::DeletingLeft), command("deleteLeft"))}@@ -566,8 +580,9 @@ impl OpenEditor {/// wordOperations.ts and wordPartOperations.ts `DeleteWordCommand`s: each cursor's range of `word_delete`,/// or nothing at the document edge, between undo stops.pub fn delete_word(&mut self, classifier: &WordClassifier, auto_closing: &AutoClosing, word_delete: WordDelete, id: &'static str) -> Option<ContentChanged> {+ let auto_closed = self.auto_closed_characters();let range = |lines: &[String], selection: Selection| {- let ctx = DeleteWordContext { classifier, lines, selection, whitespace_heuristics: word_delete.whitespace_heuristics, auto_closing };+ let ctx = DeleteWordContext { classifier, lines, selection, whitespace_heuristics: word_delete.whitespace_heuristics, auto_closing, auto_closed: &auto_closed };let range = match word_delete.kind {WordDeleteKind::Left(navigation) => word_operations::delete_word_left(&ctx, navigation),WordDeleteKind::Right(navigation) => word_operations::delete_word_right(&ctx, navigation),@@ -1563,7 +1578,7 @@ pub(super) mod tests {assert_eq!(editor.selection(), Selection::caret(at(2, 1)));editor.set_selections(vec![Selection { anchor: at(0, 3), head: at(0, 1) }]);- let change = editor.delete_left().unwrap();+ let change = editor.delete_left(&word_operations::NO_AUTO_CLOSING).unwrap();assert_eq!(text(&editor), "h\na\nbx");assert_eq!((change.changes[0].start_column, change.changes[0].end_column, change.changes[0].range_length), (2, 5, 3));}@@ -1591,9 +1606,9 @@ pub(super) mod tests {fn deletes_group_until_they_cross_a_line_or_change_direction() {let mut editor = editor("ab\ncd", "\n");editor.move_to(at(1, 2), false);- editor.delete_left();- editor.delete_left();- editor.delete_left();+ editor.delete_left(&word_operations::NO_AUTO_CLOSING);+ editor.delete_left(&word_operations::NO_AUTO_CLOSING);+ editor.delete_left(&word_operations::NO_AUTO_CLOSING);assert_eq!(text(&editor), "ab");editor.undo();assert_eq!(text(&editor), "ab\n");@@ -1774,14 +1789,14 @@ pub(super) mod tests {// Touching deletes both apply, then the cursors meet and merge.let mut touching = editor("abc", "\n");touching.set_selections(vec![range((0, 2), (0, 2)), range((0, 3), (0, 3))]);- touching.delete_left();+ touching.delete_left(&word_operations::NO_AUTO_CLOSING);assert_eq!(text(&touching), "a");assert_eq!(touching.selections, [Selection::caret(at(0, 1))]);// Overlapping deletes: the later cursor loses its edit (`_getLoserCursorMap`) and only follows the text.let mut overlapping = editor("ab cd", "\n");overlapping.set_selections(vec![range((0, 4), (0, 4)), range((0, 5), (0, 5))]);let (_, delete_word_left) = word_operations::DELETE_COMMANDS[2];- overlapping.delete_word(&WordClassifier::new(word_operations::DEFAULT_WORD_SEPARATORS, &[]), &AutoClosing { delete: "auto", brackets: "languageDefined", quotes: "languageDefined", pairs: &[], auto_closed: &[] }, delete_word_left, "deleteWordLeft");+ overlapping.delete_word(&WordClassifier::new(word_operations::DEFAULT_WORD_SEPARATORS, &[]), &word_operations::NO_AUTO_CLOSING, delete_word_left, "deleteWordLeft");assert_eq!(text(&overlapping), "ab d");assert_eq!(overlapping.selections, [Selection::caret(at(0, 3)), Selection::caret(at(0, 4))]);}diff --git a/native/crates/app/src/editor/word_operations.rs b/native/crates/app/src/editor/word_operations.rsindex d60c0451c6b..9e6c6cd5d7d 100644--- a/native/crates/app/src/editor/word_operations.rs+++ b/native/crates/app/src/editor/word_operations.rs@@ -440,15 +440,17 @@ pub const DELETE_COMMANDS: [(&str, WordDelete); 8] = {};/// `editor.autoClosingDelete`, `editor.autoClosingBrackets` and `editor.autoClosingQuotes` with the language's-/// auto-closing pairs and the auto-closed characters of the cursors (start positions).+/// auto-closing pairs.pub struct AutoClosing<'a> {pub delete: &'a str,pub brackets: &'a str,pub quotes: &'a str,pub pairs: &'a [(String, String)],- pub auto_closed: &'a [Position],}+#[cfg(test)]+pub const NO_AUTO_CLOSING: AutoClosing = AutoClosing { delete: "auto", brackets: "languageDefined", quotes: "languageDefined", pairs: &[] };+/// `DeleteWordContext`.pub struct DeleteWordContext<'a> {pub classifier: &'a WordClassifier,@@ -456,6 +458,8 @@ pub struct DeleteWordContext<'a> {pub selection: Selection,pub whitespace_heuristics: bool,pub auto_closing: &'a AutoClosing<'a>,+ /// The starts of the cursors' auto-closed characters.+ pub auto_closed: &'a [Position],}pub type Range = (Position, Position);@@ -466,7 +470,7 @@ fn ordered(a: Position, b: Position) -> Range {/// `DeleteOperations.isAutoClosingPairDelete` for one cursor: the cursor sits between an auto-closing pair's/// one-char open and its close.-fn is_auto_closing_pair_delete(auto_closing: &AutoClosing, lines: &[String], selection: Selection) -> bool {+pub(super) fn is_auto_closing_pair_delete(auto_closing: &AutoClosing, auto_closed: &[Position], lines: &[String], selection: Selection) -> bool {if auto_closing.brackets == "never" && auto_closing.quotes == "never" || auto_closing.delete == "never" || !selection.is_empty() {return false;}@@ -486,7 +490,7 @@ fn is_auto_closing_pair_delete(auto_closing: &AutoClosing, lines: &[String], sel}let found = candidates.iter().any(|(open, close)| open.chars().eq([character]) && close.chars().eq([after]));// `auto` deletes only a pair the editor inserted itself.- found && (auto_closing.delete != "auto" || auto_closing.auto_closed.contains(&position))+ found && (auto_closing.delete != "auto" || auto_closed.contains(&position))}/// `_deleteWordLeftWhitespace`: two or more blanks before the cursor.@@ -503,7 +507,7 @@ pub fn delete_word_left(ctx: &DeleteWordContext, navigation: WordNavigation) ->return Some((selection.start(), selection.end()));}let position = selection.head;- if is_auto_closing_pair_delete(ctx.auto_closing, ctx.lines, selection) {+ if is_auto_closing_pair_delete(ctx.auto_closing, ctx.auto_closed, ctx.lines, selection) {return Some((Position::new(position.line, position.column - 1), Position::new(position.line, position.column + 1)));}if position == Position::new(0, 0) {diff --git a/native/crates/app/src/editor/word_operations/tests.rs b/native/crates/app/src/editor/word_operations/tests.rsindex e9c60b82ed7..77d3ba7ccd2 100644--- a/native/crates/app/src/editor/word_operations/tests.rs+++ b/native/crates/app/src/editor/word_operations/tests.rs@@ -18,7 +18,6 @@ fn value(editor: &OpenEditor) -> String {editor.document().lines.join("\n")}-const NO_AUTO_CLOSING: AutoClosing = AutoClosing { delete: "auto", brackets: "languageDefined", quotes: "languageDefined", pairs: &[], auto_closed: &[] };fn run_move(editor: &mut OpenEditor, id: &str, locales: &[String]) {let (_, word_move) = MOVE_COMMANDS.into_iter().find(|(command, _)| *command == id).expect("a word move command");diff --git a/native/crates/app/src/workbench/editor_commands.rs b/native/crates/app/src/workbench/editor_commands.rsindex a0b75176dc3..22895b7b647 100644--- a/native/crates/app/src/workbench/editor_commands.rs+++ b/native/crates/app/src/workbench/editor_commands.rs@@ -19,7 +19,7 @@ use crate::editor::{CaseTransform, ContentChanged, LineCommentKind, OpenEditor,type EditorCommand = fn(&mut OpenEditor) -> Option<ContentChanged>;/// Cursor and edit commands: `EditorCommand`s, which run on the focused editor or else the active one.-const EDITOR_COMMANDS: [(&str, EditorCommand); 34] = [+const EDITOR_COMMANDS: [(&str, EditorCommand); 33] = [("cursorLeft", |editor| { editor.move_horizontally(false, false); None }),("cursorLeftSelect", |editor| { editor.move_horizontally(false, true); None }),("cursorRight", |editor| { editor.move_horizontally(true, false); None }),@@ -37,7 +37,6 @@ const EDITOR_COMMANDS: [(&str, EditorCommand); 34] = [("cursorBottom", |editor| { editor.move_to_document_edge(true, false); None }),("cursorBottomSelect", |editor| { editor.move_to_document_edge(true, true); None }),("expandLineSelection", |editor| { editor.expand_line_selection(); None }),- ("deleteLeft", OpenEditor::delete_left),("deleteRight", OpenEditor::delete_right),("deleteAllLeft", OpenEditor::delete_all_left),("deleteAllRight", OpenEditor::delete_all_right),@@ -85,7 +84,7 @@ impl Workbench {pub(super) fn register_editor_commands(&mut self) {for (id, command) in EDITOR_COMMANDS {let edit = !id.starts_with("cursor") && id != "expandLineSelection";- let cursor_edit = matches!(id, "deleteLeft" | "deleteRight");+ let cursor_edit = id == "deleteRight";self.commands.register(id, move |workbench, _, _, cx| {if edit && workbench.edit_blocked(cursor_edit, cx) {return Outcome::done();@@ -93,6 +92,12 @@ impl Workbench {workbench.run_on_active_editor(command, cx)});}+ self.commands.register("deleteLeft", |workbench, _, _, cx| {+ if workbench.edit_blocked(true, cx) {+ return Outcome::done();+ }+ workbench.run_with_auto_closing(OpenEditor::delete_left, cx)+ });self.register_word_commands();for (id, command) in INDENTING_EDITOR_COMMANDS {self.commands.register(id, move |workbench, _, _, cx| {@@ -529,11 +534,15 @@ impl Workbench {Some((separators.to_string(), locales))}- /// `DeleteWordCommand.runEditorCommand` with the auto-closing settings and pairs of the editor's language.- /// The port does not auto-close typed brackets, so no cursor has auto-closed characters.+ /// `DeleteWordCommand.runEditorCommand`.fn run_word_delete(&mut self, word_delete: WordDelete, id: &'static str, cx: &mut Context<Self>) -> Outcome {let Some(classifier) = self.word_classifier(false) else { return Outcome::done() };- let editor = self.editors.active().expect("word_classifier found it");+ self.run_with_auto_closing(|editor, auto_closing| editor.delete_word(&classifier, auto_closing, word_delete, id), cx)+ }++ /// Runs `command` on the active editor with the auto-closing settings and pairs of its language.+ fn run_with_auto_closing(&mut self, command: impl FnOnce(&mut OpenEditor, &AutoClosing) -> Option<ContentChanged>, cx: &mut Context<Self>) -> Outcome {+ let Some(editor) = self.editors.active() else { return Outcome::done() };let (resource, language) = (editor.document().path.clone(), editor.document().language_id.clone());let overrides = Overrides { resource: Some(&resource), override_identifier: Some(&language) };let settings = self.settings.lock().unwrap();@@ -542,8 +551,8 @@ impl Workbench {drop(settings);let language = editor.document().language_id.clone();let pairs = self.languages.rules(&language).map(|rules| rules.auto_closing_pairs.clone()).unwrap_or_default();- let auto_closing = AutoClosing { delete: &delete, brackets: &brackets, quotes: "es, pairs: &pairs, auto_closed: &[] };- self.run_on_active_editor(|editor| editor.delete_word(&classifier, &auto_closing, word_delete, id), cx)+ let auto_closing = AutoClosing { delete: &delete, brackets: &brackets, quotes: "es, pairs: &pairs };+ self.run_on_active_editor(|editor| command(editor, &auto_closing), cx)}/// Runs an editor command, then tells the host and scrolls the cursor into view as a key press does.diff --git a/port/ledger.md b/port/ledger.mdindex 053f30e4d2f..b24a74c7f2e 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: Delete Left does not delete an auto-closed pair (cursor.test.ts autoClosing 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 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/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 767b0b595a7..4124cb4c067 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.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. 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, #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. 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).- 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`.@@ -881,7 +881,7 @@ Scope as in the M19 Work row of port/ledger.md.## Milestones 5 to 7: the remaining rows- Word operations (`editor/word_operations.rs`) port cursorWordOperations.ts whole: the four `WordNavigation`s, the 16 `cursorWord*` moves, the 8 `deleteWord*` deletes and Delete Word (`deleteInsideWord` with `onlyWord`), read with the editor's `editor.wordSeparators` (the accessibility moves keep the default) and `editor.wordSegmenterLocales`. `Intl.Segmenter` words come from `icu_segmenter`'s dictionary word segmenter, the ICU rules V8 runs. shortcut: a well-formed locale tag counts as supported, where V8 also drops tags ICU has no data for.-- `deleteWordLeft` deletes an auto-closing pair around the cursor as upstream (`editor.autoClosingDelete`, the language's `autoClosingPairs`); with the default `auto` the pair must have been auto-closed, and the port does not auto-close typed brackets yet, so only `always` deletes one.+- `deleteWordLeft` deletes an auto-closing pair around the cursor as upstream (`editor.autoClosingDelete`, the language's `autoClosingPairs`); with the default `auto` the pair must have been auto-closed. Delete Left does the same when every cursor sits in such a pair (`DeleteOperations.deleteLeft`).- Clipboard (clipboard.ts, clipboardUtils.ts): copy writes the text with `ClipboardStoredMetadata` (`isFromEmptySelection`, `isBlock`, `multicursorText`, `mode`) in GPUI's clipboard metadata, and `getRichTextToCopy`'s HTML as `public.html` with the `<meta charset='utf-8'>` Chromium's macOS writer adds (`editor/clipboard.rs`). A copy of a column selection pastes as a block at one cursor (`ColumnSelectionPasteCommand`) with `editor.multiCursorPaste` spread. The HTML font comes from the `editor.font*` settings and the editor zoom, as upstream's font info, though the port draws Menlo 12. shortcut: the block paste counts graphemes and wide chars (`CursorColumns`), the rest of the port one column per char.- The Copy As and Share submenus are not shown: no built-in extension contributes to `menuBar/edit/copy` or `editor/context/copy`, and Share's only item (github's vscode.dev link) needs a GitHub repository and the removed share service, so upstream hides both empty submenus too.- Host console, errors and activation errors: the session keeps printing and answering them on stderr (the api-tests logs read them), and hands the workbench a copy with `OBSERVED_REQ`, which `cancel` drops instead of answering. The workbench writes them to the Window log as mainThreadConsole.ts and mainThreadErrors.ts do: errors only, labeled `[Extension Host]`, in a normal window; every entry, unlabeled, with `--extensionTestsPath`. Unexpected errors pass `createUnexpectedErrorHandler` (same text within 1000 ms dropped).