Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(editor): surround selections with typed pairs

rokarture596bc69c219
diff --git a/native/crates/app/src/editor/auto_closing.rs b/native/crates/app/src/editor/auto_closing.rs
index 38ba994a7df..6eb25c5e7bb 100644
--- a/native/crates/app/src/editor/auto_closing.rs
+++ b/native/crates/app/src/editor/auto_closing.rs
@@ -7,8 +7,8 @@ use textmate::StandardTokenType;
use super::OpenEditor;
use super::auto_indent::{AutoIndent, parse_regex};
-use super::cursor::Position;
-use super::edit::{ContentChanged, CursorEdit, EditKind, TYPED};
+use super::cursor::{Position, Selection};
+use super::edit::{ContentChanged, CursorEdit, EditKind, Replace, TYPED};
use super::word_operations::{CharClass, DEFAULT_WORD_SEPARATORS, WordClassifier};
/// characterPair.ts `DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED_QUOTES` and `..._BRACKETS`.
@@ -55,12 +55,14 @@ pub struct Options<'a> {
pub comments: AutoClose,
/// `editor.autoClosingOvertype`: "always", "auto" or "never".
pub overtype: &'a str,
+ /// `editor.autoSurround`: "languageDefined", "quotes", "brackets" or "never".
+ pub surround: &'a str,
pub word_separators: &'a str,
}
impl Default for Options<'_> {
fn default() -> Self {
- Options { brackets: AutoClose::LanguageDefined, quotes: AutoClose::LanguageDefined, comments: AutoClose::LanguageDefined, overtype: "auto", word_separators: DEFAULT_WORD_SEPARATORS }
+ Options { brackets: AutoClose::LanguageDefined, quotes: AutoClose::LanguageDefined, comments: AutoClose::LanguageDefined, overtype: "auto", surround: "languageDefined", word_separators: DEFAULT_WORD_SEPARATORS }
}
}
@@ -84,20 +86,26 @@ impl Pair {
}
}
-/// `CharacterPairSupport`: the `autoClosingPairs`, else the brackets, and `autoCloseBefore`.
+/// `CharacterPairSupport`: the `autoClosingPairs`, else the brackets, `autoCloseBefore`, and the `surroundingPairs`, else
+/// the auto-closing pairs.
#[derive(Default)]
pub struct CharacterPairs {
pub pairs: Vec<Pair>,
auto_close_before: Option<String>,
+ surrounding: Vec<(String, String)>,
}
impl CharacterPairs {
pub fn new(language: &str, config: &Value, brackets: Option<&[(String, String)]>) -> Self {
- let pairs = match config["autoClosingPairs"].as_array() {
+ let pairs: Vec<Pair> = match config["autoClosingPairs"].as_array() {
Some(pairs) => pairs.iter().enumerate().filter_map(|(i, pair)| auto_closing_pair(language, i, pair)).collect(),
None => brackets.unwrap_or_default().iter().map(|(open, close)| Pair { open: open.clone(), close: close.clone(), not_in: Vec::new(), before_text: None }).collect(),
};
- CharacterPairs { pairs, auto_close_before: config["autoCloseBefore"].as_str().map(str::to_string) }
+ let surrounding = match config["surroundingPairs"].as_array() {
+ Some(surrounding) => surrounding.iter().filter_map(|pair| Some((pair[0].as_str().or(pair["open"].as_str())?.to_string(), pair[1].as_str().or(pair["close"].as_str())?.to_string()))).collect(),
+ None => pairs.iter().map(|pair| (pair.open.clone(), pair.close.clone())).collect(),
+ };
+ CharacterPairs { pairs, auto_close_before: config["autoCloseBefore"].as_str().map(str::to_string), surrounding }
}
/// `getAutoCloseBeforeSet`.
@@ -316,6 +324,58 @@ impl OpenEditor {
Some((pair.open.clone(), close))
}
+ /// `SurroundSelectionOperation`: typing a surrounding pair's open wraps every selection in the pair, which stays
+ /// selected, between undo stops.
+ pub(super) fn surround_selection(&mut self, ch: char, auto: AutoIndent) -> Option<Vec<ContentChanged>> {
+ let close = self.surrounding_close(ch, auto)?;
+ let edits = self.each_cursor(|selection| {
+ let (start, end) = (selection.start(), selection.end());
+ let open = Replace { start, end: start, text: ch.to_string() };
+ let close = Replace { start: end, end, text: close.clone() };
+ let shift = usize::from(start.line == end.line);
+ CursorEdit::new(vec![open, close], Selection { anchor: Position::new(start.line, start.column + 1), head: Position::new(end.line, end.column + shift) })
+ });
+ Some(self.apply_between_stops(edits, TYPED).into_iter().collect())
+ }
+
+ /// `_isSurroundSelectionType` with `shouldSurroundChar`: the close of the pair `ch` opens when every selection
+ /// holds more than blanks and none is one quote typed over with a quote.
+ fn surrounding_close(&self, ch: char, auto: AutoIndent) -> Option<String> {
+ let surround = auto.closing.surround;
+ let allowed = match is_quote(ch) {
+ true => matches!(surround, "quotes" | "languageDefined"),
+ false => matches!(surround, "brackets" | "languageDefined"),
+ };
+ if !allowed {
+ return None;
+ }
+ let document = self.document();
+ let surrounding = &auto.languages.rules(&document.language_id)?.character_pairs.surrounding;
+ // Upstream keeps the pairs in a map by open, so the last one wins.
+ let (_, close) = surrounding.iter().rev().find(|(open, _)| open.chars().eq([ch]))?;
+ for selection in &self.selections {
+ let (start, end) = (selection.start(), selection.end());
+ if selection.is_empty() {
+ return None;
+ }
+ let mut selected = String::new();
+ for line in start.line..=end.line {
+ let text = &document.lines[line];
+ let from = if line == start.line { byte_offset(text, start.column) } else { 0 };
+ let to = if line == end.line { byte_offset(text, end.column) } else { text.len() };
+ selected.push_str(&text[from..to]);
+ }
+ if selected.chars().all(|c| c == ' ' || c == '\t') {
+ return None;
+ }
+ let mut chars = selected.chars();
+ if is_quote(ch) && start.line == end.line && chars.next().is_some_and(is_quote) && chars.next().is_none() {
+ return None;
+ }
+ }
+ Some(close.clone())
+ }
+
/// `_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.rs
index a46f8bbd4f0..9f9cac2b82f 100644
--- a/native/crates/app/src/editor/auto_closing/tests.rs
+++ b/native/crates/app/src/editor/auto_closing/tests.rs
@@ -62,6 +62,11 @@ impl Cursor {
self
}
+ fn surround(mut self, surround: &'static str) -> Self {
+ self.options.surround = surround;
+ 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");
@@ -75,6 +80,17 @@ impl Cursor {
self.editor.set_selections(carets.iter().map(|&(line, column)| Selection::caret(Position::new(line - 1, column - 1))).collect());
}
+ /// Selections from (line, column) to (line, column).
+ fn select_ranges(&mut self, ranges: &[((usize, usize), (usize, usize))]) {
+ let position = |(line, column): (usize, usize)| Position::new(line - 1, column - 1);
+ self.editor.set_selections(ranges.iter().map(|&(anchor, head)| Selection { anchor: position(anchor), head: position(head) }).collect());
+ }
+
+ fn selections(&self) -> Vec<((usize, usize), (usize, usize))> {
+ let position = |position: Position| (position.line + 1, position.column + 1);
+ self.editor.selections.iter().map(|selection| (position(selection.anchor), position(selection.head))).collect()
+ }
+
/// `viewModel.type(text, 'keyboard')`.
fn type_text(&mut self, text: &str) {
let auto = AutoIndent { languages: &self.languages, strategy: Strategy::Full, closing: self.options };
@@ -511,3 +527,71 @@ fn issue_84998_overtyping_brackets_does_not_work_after_backslash() {
cursor.type_text(")");
assert_eq!(cursor.value(), "\\(abc\\)");
}
+
+#[test]
+fn auto_wrapping_is_configurable() {
+ let mut cursor = Cursor::new(auto_closing_language(), &["var a = asd"]);
+ cursor.select_ranges(&[((1, 1), (1, 4)), ((1, 9), (1, 12))]);
+ cursor.type_text("`");
+ assert_eq!(cursor.value(), "`var` a = `asd`");
+ cursor.type_text("(");
+ assert_eq!(cursor.value(), "`(var)` a = `(asd)`");
+
+ let mut cursor = Cursor::new(auto_closing_language(), &["var a = asd"]).surround("never");
+ cursor.select_ranges(&[((1, 1), (1, 4))]);
+ cursor.type_text("`");
+ assert_eq!(cursor.value(), "` a = asd");
+
+ let mut cursor = Cursor::new(auto_closing_language(), &["var a = asd"]).surround("quotes");
+ cursor.select_ranges(&[((1, 1), (1, 4))]);
+ cursor.type_text("`");
+ assert_eq!(cursor.value(), "`var` a = asd");
+ cursor.type_text("(");
+ assert_eq!(cursor.value(), "`(` a = asd");
+
+ let mut cursor = Cursor::new(auto_closing_language(), &["var a = asd"]).surround("brackets");
+ cursor.select_ranges(&[((1, 1), (1, 4))]);
+ cursor.type_text("(");
+ assert_eq!(cursor.value(), "(var) a = asd");
+ cursor.type_text("`");
+ assert_eq!(cursor.value(), "(`) a = asd");
+}
+
+#[test]
+fn bug_11476_double_bracket_surrounding_and_undo_is_broken() {
+ let mut cursor = Cursor::new(json!({ "autoClosingPairs": [{ "open": "(", "close": ")" }] }), &["hello"]);
+ cursor.select_ranges(&[((1, 3), (1, 5))]);
+ cursor.type_text("(");
+ assert_eq!(cursor.selections(), [((1, 4), (1, 6))]);
+ cursor.type_text("(");
+ assert_eq!(cursor.selections(), [((1, 5), (1, 7))]);
+}
+
+#[test]
+fn issue_206774_surround_selection_with_empty_close_does_not_throw() {
+ let mut cursor = Cursor::new(json!({ "surroundingPairs": [{ "open": "<", "close": "" }] }), &["hello world"]);
+ cursor.select_ranges(&[((1, 1), (1, 6))]);
+ cursor.type_text("<");
+ assert_eq!(cursor.value(), "<hello world");
+}
+
+#[test]
+fn issue_47733_undo_mangles_unicode_characters() {
+ let mut cursor = Cursor::new(json!({ "surroundingPairs": [{ "open": "%", "close": "%" }] }), &["'πŸ‘'"]);
+ cursor.select_ranges(&[((1, 1), (1, 2))]);
+ cursor.type_text("%");
+ assert_eq!(cursor.value(), "%'%πŸ‘'");
+ cursor.editor.undo();
+ assert_eq!(cursor.value(), "'πŸ‘'");
+}
+
+#[test]
+fn issue_41825_special_handling_of_quotes_in_surrounding_pairs() {
+ let mut cursor = Cursor::new(json!({ "surroundingPairs": [{ "open": "\"", "close": "\"" }, { "open": "'", "close": "'" }] }), &["var x = 'hi';"]);
+ cursor.select_ranges(&[((1, 9), (1, 10)), ((1, 12), (1, 13))]);
+ cursor.type_text("\"");
+ assert_eq!(cursor.value(), "var x = \"hi\";");
+ cursor.select_ranges(&[((1, 9), (1, 10)), ((1, 12), (1, 13))]);
+ cursor.type_text("'");
+ assert_eq!(cursor.value(), "var x = 'hi';");
+}
diff --git a/native/crates/app/src/editor/edit.rs b/native/crates/app/src/editor/edit.rs
index 536318b9fd7..f494a4cacb6 100644
--- a/native/crates/app/src/editor/edit.rs
+++ b/native/crates/app/src/editor/edit.rs
@@ -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_overtype(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)).or_else(|| self.surround_selection(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.rs
index 10fb1bf79ae..a0b75176dc3 100644
--- a/native/crates/app/src/workbench/editor_commands.rs
+++ b/native/crates/app/src/workbench/editor_commands.rs
@@ -566,7 +566,8 @@ impl Workbench {
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 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 };
+ let surround = setting("editor.autoSurround").and_then(|value| value.as_str().map(str::to_string)).unwrap_or("languageDefined".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, surround: &surround, word_separators: &word_separators };
drop(settings);
let selections_before = editor.selections.clone();
drop(document);
diff --git a/port/ledger.md b/port/ledger.md
index 154fb5e6deb..053f30e4d2f 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 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/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/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.md
index 50f4b01a60c..767b0b595a7 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`, 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).
+- 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).
- 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`.