Skip to content

Visual Studio Code, rebuilt in Rust

Rust

perf(editor): keep each line's brackets until its tokens change

rokarturaae9ceb7b8a8
diff --git a/native/crates/app/src/brackets.rs b/native/crates/app/src/brackets.rs
index 3524088ac5b..6015f9769f3 100644
--- a/native/crates/app/src/brackets.rs
+++ b/native/crates/app/src/brackets.rs
@@ -4,13 +4,14 @@
use std::collections::HashMap;
use std::ops::Range;
+use std::sync::Arc;
use serde_json::Value;
use textmate::{StandardTokenType, Style};
/// The brackets of one language: `LanguageBracketsConfiguration` turned into `BracketTokens`.
pub struct LanguageBrackets {
- tokens: HashMap<String, BracketToken>,
+ tokens: HashMap<String, Arc<BracketToken>>,
regex: Option<onig::Regex>,
}
@@ -56,10 +57,10 @@ impl LanguageBrackets {
}
let mut tokens = HashMap::new();
for open in openings {
- tokens.insert(open.to_string(), BracketToken { opening: true, id: id(open), ids: vec![id(open)], colorized_openings: Vec::new() });
+ tokens.insert(open.to_string(), Arc::new(BracketToken { opening: true, id: id(open), ids: vec![id(open)], colorized_openings: Vec::new() }));
}
for (close, opened, colorized_openings) in closings {
- tokens.insert(close.to_string(), BracketToken { opening: false, id: opened[0].clone(), ids: opened, colorized_openings });
+ tokens.insert(close.to_string(), Arc::new(BracketToken { opening: false, id: opened[0].clone(), ids: opened, colorized_openings }));
}
let mut texts: Vec<&String> = tokens.keys().collect();
texts.sort();
@@ -72,7 +73,7 @@ impl LanguageBrackets {
}
/// `BracketTokens.getToken`: the map holds the configured texts, the lookup is lower case.
- fn token(&self, text: &str) -> Option<&BracketToken> {
+ fn token(&self, text: &str) -> Option<&Arc<BracketToken>> {
self.tokens.get(&text.to_lowercase())
}
@@ -184,8 +185,18 @@ pub struct DocumentBrackets {
impl DocumentBrackets {
pub fn new(lines: &[(&str, Vec<Span>)], languages: &HashMap<String, LanguageBrackets>) -> Self {
- let found = scan(lines, languages);
+ let found: Vec<_> = lines.iter().map(|(text, spans)| line_brackets(text, spans, languages)).collect();
+ let found: Vec<_> = found.iter().map(Vec::as_slice).collect();
let document_end = lines.last().map_or((0, 0), |(text, _)| (lines.len() - 1, text.len()));
+ DocumentBrackets::from_lines(&found, document_end)
+ }
+
+ /// The pairs over the brackets of each line; an unclosed pair at the end runs to `document_end`.
+ pub fn from_lines(lines: &[&[LineBracket]], document_end: (usize, usize)) -> Self {
+ let mut found = Vec::new();
+ for (line, brackets) in lines.iter().enumerate() {
+ found.extend(brackets.iter().map(|bracket| Found { line, range: bracket.range.clone(), token: &bracket.token }));
+ }
let mut parser = Parser { found: &found, next: 0, document_end };
let mut nodes = Vec::new();
while parser.next < found.len() {
@@ -241,36 +252,41 @@ struct Found<'a> {
token: &'a BracketToken,
}
-/// `NonPeekableTextBufferTokenizer.read`: brackets only in `Other` tokens that may hold balanced
+/// A bracket on a line: it holds as long as the line's text and tokens do.
+#[derive(Clone)]
+pub struct LineBracket {
+ range: Range<usize>,
+ token: Arc<BracketToken>,
+}
+
+/// `NonPeekableTextBufferTokenizer.read` over one line: brackets only in `Other` tokens that may hold balanced
/// brackets, with neighbor tokens of equal metadata read as one.
-fn scan<'a>(lines: &[(&str, Vec<Span>)], languages: &'a HashMap<String, LanguageBrackets>) -> Vec<Found<'a>> {
+pub fn line_brackets(text: &str, spans: &[Span], languages: &HashMap<String, LanguageBrackets>) -> Vec<LineBracket> {
let mut found = Vec::new();
- for (line, (text, spans)) in lines.iter().enumerate() {
- let (mut position, mut index) = (0, 0);
- while index < spans.len() {
- let span = spans[index];
- while index + 1 < spans.len() && spans[index + 1].same_metadata(&span) {
- index += 1;
- }
- let end = spans[index].end.min(text.len());
- let mut bracket = None;
- if span.token_type == StandardTokenType::Other && span.balanced_brackets && position < end
- && let Some(brackets) = languages.get(span.language)
- && let Some(regex) = &brackets.regex
- && let Some((start, match_end)) = regex.find(&text[position..end])
- {
- bracket = brackets.token(&text[position + start..position + match_end]).map(|token| (position + start..position + match_end, token));
+ let (mut position, mut index) = (0, 0);
+ while index < spans.len() {
+ let span = spans[index];
+ while index + 1 < spans.len() && spans[index + 1].same_metadata(&span) {
+ index += 1;
+ }
+ let end = spans[index].end.min(text.len());
+ let mut bracket = None;
+ if span.token_type == StandardTokenType::Other && span.balanced_brackets && position < end
+ && let Some(brackets) = languages.get(span.language)
+ && let Some(regex) = &brackets.regex
+ && let Some((start, match_end)) = regex.find(&text[position..end])
+ {
+ bracket = brackets.token(&text[position + start..position + match_end]).map(|token| (position + start..position + match_end, token));
+ }
+ match bracket {
+ // A token can hold more brackets, so read on from the bracket's end.
+ Some((range, token)) => {
+ position = range.end;
+ found.push(LineBracket { range, token: token.clone() });
}
- match bracket {
- // A token can hold more brackets, so read on from the bracket's end.
- Some((range, token)) => {
- position = range.end;
- found.push(Found { line, range, token });
- }
- None => {
- index += 1;
- position = end;
- }
+ None => {
+ index += 1;
+ position = end;
}
}
}
diff --git a/native/crates/app/src/syntax.rs b/native/crates/app/src/syntax.rs
index b922005a699..399e2a16091 100644
--- a/native/crates/app/src/syntax.rs
+++ b/native/crates/app/src/syntax.rs
@@ -9,7 +9,7 @@ use gpui::{FontStyle, FontWeight, HighlightStyle, Hsla, Rgba, StrikethroughStyle
use serde_json::{Map, Value, json};
use textmate::{Grammar, State, Token};
-use crate::brackets::{BracketGuide, BracketGuideOptions, BracketRange, DocumentBrackets, Span};
+use crate::brackets::{BracketGuide, BracketGuideOptions, BracketRange, DocumentBrackets, LineBracket, Span, line_brackets};
use crate::languages::Languages;
use crate::theme::{Theme, ThemeKind};
@@ -103,6 +103,10 @@ struct TokenStore {
tokens: Vec<Vec<Token>>,
end_states: Vec<Option<State>>,
invalid: InvalidLines,
+ /// Each line's brackets under the drawing theme, and under the empty theme `pairs` reads, until its text or
+ /// tokens change.
+ brackets: Vec<Option<Vec<LineBracket>>>,
+ plain_brackets: Vec<Option<Vec<LineBracket>>>,
}
impl TokenStore {
@@ -112,6 +116,8 @@ impl TokenStore {
self.end_states = vec![None; line_count];
self.invalid = InvalidLines::default();
self.invalid.add_range(0..line_count);
+ self.brackets = vec![None; line_count];
+ self.plain_brackets = vec![None; line_count];
}
/// `setEndState`: an end state that changed makes the next line's end state untrusted.
@@ -309,10 +315,10 @@ impl Tokenization {
}
/// The bracket pairs of the document in `language`, also without a grammar.
- // shortcut: pairs the whole document per call, where upstream queries its incremental bracket tree.
+ // shortcut: pairs all lines' brackets per call, where upstream queries its incremental bracket tree.
pub fn pairs(&self, languages: &Languages, lines: &[String], language: &str) -> DocumentBrackets {
if self.grammar.is_some() {
- return self.document_brackets(&textmate::Theme::new(&[]), languages, lines);
+ return self.document_brackets(&textmate::Theme::new(&[]), languages, lines, true);
}
// nullTokenize: one Other token over each line, in the model's language.
let style = textmate::Style { font_style: 0, foreground: 0, background: 0 };
@@ -346,8 +352,8 @@ impl Tokenization {
/// `acceptChange` after an edit that replaced lines `start..=end` by `new_line_count` lines: their end states
/// are untrusted, the last one kept to compare with; the first line keeps its stale tokens, the others have none
/// until tokenized. The bracket pairs are dropped.
- // shortcut: re-pairs all brackets, where upstream updates its BracketPairsTree incrementally; upgrade when typing in
- // large files lags.
+ // shortcut: pairs the brackets of all lines again (6.5 ms for 78k brackets), where upstream's BracketPairsTree reuses
+ // the unchanged nodes; upgrade when the typing_latency_on_a_large_file gate fails on the pairing.
pub fn accept_edit(&mut self, start: usize, end: usize, new_line_count: usize) {
self.brackets = OnceCell::new();
let store = self.lines.get_mut();
@@ -357,6 +363,8 @@ impl Tokenization {
store.tokens.splice(start + 1..=end, (1..new_line_count).map(|_| Vec::new()));
store.end_states.splice(start..end, (1..new_line_count).map(|_| None));
store.invalid.add_range_and_resize(start..end + 1, new_line_count);
+ store.brackets.splice(start..=end, (0..new_line_count).map(|_| None));
+ store.plain_brackets.splice(start..=end, (0..new_line_count).map(|_| None));
}
/// tokenization.ts `ForceRetokenizeAction`: `resetTokenization`, then `forceTokenization` of every line.
@@ -381,21 +389,27 @@ impl Tokenization {
/// The bracket pairs hold token styles of the theme they were paired under.
pub fn theme_changed(&mut self) {
self.brackets = OnceCell::new();
+ self.lines.get_mut().brackets.fill(None);
}
fn brackets(&self, theme: &Theme, languages: &Languages, lines: &[String]) -> &DocumentBrackets {
- self.brackets.get_or_init(|| self.document_brackets(&theme.tokens, languages, lines))
+ self.brackets.get_or_init(|| self.document_brackets(&theme.tokens, languages, lines, false))
}
/// The bracket pairs over the tokens as they are, as bracketPairsTree.ts reads the token store while the background
/// tokenizer runs: a line not tokenized yet holds no brackets. The lines an edit left untrusted are tokenized first,
- /// `BRACKET_TOKENIZE_LINES` at most, so the edited line's brackets count.
- fn document_brackets(&self, theme: &textmate::Theme, languages: &Languages, lines: &[String]) -> DocumentBrackets {
+ /// `BRACKET_TOKENIZE_LINES` at most, so the edited line's brackets count. Only lines whose text or tokens changed
+ /// are read again; `plain` picks the brackets under the empty theme.
+ fn document_brackets(&self, theme: &textmate::Theme, languages: &Languages, lines: &[String], plain: bool) -> DocumentBrackets {
self.tokenize_for(lines, Duration::MAX, BRACKET_TOKENIZE_LINES);
- let tokenized = self.synced(lines);
- let mut spans = Vec::new();
- for (text, tokens) in lines.iter().zip(&tokenized.tokens) {
- let line_spans = tokens
+ let mut store = self.synced(lines);
+ let store = &mut *store;
+ let cache = if plain { &mut store.plain_brackets } else { &mut store.brackets };
+ for ((text, tokens), brackets) in lines.iter().zip(&store.tokens).zip(cache.iter_mut()) {
+ if brackets.is_some() {
+ continue;
+ }
+ let spans: Vec<_> = tokens
.iter()
.map(|token| Span {
end: token.end,
@@ -405,9 +419,11 @@ impl Tokenization {
style: theme.style(&token.scopes),
})
.collect();
- spans.push((text.as_str(), line_spans));
+ *brackets = Some(line_brackets(text, &spans, &languages.brackets));
}
- DocumentBrackets::new(&spans, &languages.brackets)
+ let found: Vec<_> = cache.iter().map(|brackets| brackets.as_deref().expect("every line's brackets were just read")).collect();
+ let document_end = lines.last().map_or((0, 0), |text| (lines.len() - 1, text.len()));
+ DocumentBrackets::from_lines(&found, document_end)
}
/// `updateTokensUntilLine`: tokenizes each line with an untrusted end state up to line `index`.
@@ -486,6 +502,8 @@ impl Tokenization {
(None, None) => (Vec::new(), grammar.tokenize_line("", None).expect("an empty line tokenizes").1),
};
store.tokens[line] = tokens;
+ store.brackets[line] = None;
+ store.plain_brackets[line] = None;
store.set_end_state(line, state);
}
}
@@ -641,6 +659,22 @@ mod tests {
assert_eq!(tokens.line_tokens(&lines, 2).iter().find(|(_, token_type, _)| *token_type == textmate::StandardTokenType::Comment), None);
}
+ /// Each line's brackets are found again after an edit to it, and after a retokenizing that changed its tokens.
+ #[test]
+ fn a_line_s_brackets_are_read_again_when_its_text_or_tokens_change() {
+ let extensions = exthost::scan::scan_builtin_extensions(&Path::new(env!("VSCODE_SRC")).join("extensions")).unwrap();
+ let languages = Languages::new(&extensions);
+ let mut lines: Vec<String> = ["f(1);", "g(2);"].map(String::from).into();
+ let mut tokens = Tokenization::new(languages.grammars.grammar("typescript"));
+ assert_eq!(tokens.pairs(&languages, &lines, "typescript").pairs.len(), 2);
+ lines[0] = "f((1);".into();
+ tokens.accept_edit(0, 0, 1);
+ assert_eq!(tokens.pairs(&languages, &lines, "typescript").pairs.len(), 3);
+ lines[0] = "/* f(1);".into();
+ tokens.accept_edit(0, 0, 1);
+ assert_eq!(tokens.pairs(&languages, &lines, "typescript").pairs.len(), 0, "the comment opened above hides line 2's brackets");
+ }
+
/// Typing latency on a 52k-line TypeScript file (textModel.ts repeated): the median per edit of one typed char
/// then the tokens of 60 visible lines and the bracket match, at lines 100, 25000 and 49000; the gate is 16 ms.
/// Run in release: `cargo test --release -p app -- --ignored typing_latency_on_a_large_file --nocapture`.
diff --git a/port/ledger.md b/port/ledger.md
index 8701f5641ac..db166dd2c86 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -285,8 +285,8 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| platform/windows | src/vs/platform | M11 | verified | | windows_state.rs (windowsStateHandler.ts, windowsMainService.ts `doGetPathsFromLastSession`): `windowsState` in `User/globalStorage/storage.json` saved on quit (the last window closed, else the active one; all windows when two or more), restored on a start without paths and on every start with `preserve` (`window.restoreWindows` none, one, folders, all), each window in its display and bounds when that display is still there, fullscreen only with `window.restoreFullscreen`; empty windows reopen on their backup folder; a reload keeps the window's place; a new window takes the stored place of its workspace, folder or empty window, the first one the last active window's, else `window.newWindowDimensions` (default and offset cascade 30 points off the open windows, inherit, maximized, fullscreen). The default size stays 1024x768, the reference capture size of port/tools/ref-screenshot, where upstream takes 1200x800 or 1440x900. `cargo test -p app windows_state`; verified: ui-pair hot-exit.json `restored` vs the reference (port/results/windows.md, milestone 11 verification): the window restored on its folder after quit |
| 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:136: a view line starting inside an inlay hint in a smaller font or with the padding box draws the hint's rest at an even share of its drawn width, upstream splits the spans <br> [3 L] syntax.rs:312, :349: incremental bracket tree. Gate: cargo test --release -p app -- --ignored typing_latency_on_a_large_file (one typed char then the tokens of 60 visible lines and the bracket match, 52k-line TS file of textModel.ts repeated, median per edit under 16 ms). Before the token store (80b459587ac): 5.6 s at line 100, 2.8 s at line 25000, 0.5 s at line 49000. With it: 238 ms, 221 ms, 270 ms, each edit re-pairing all brackets <br> [3 S] syntax.rs:135: no `tokenizeHeuristically`, the viewport is tokenized from the first untrusted line <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] syntax.rs:312, :349: incremental bracket tree. Gate: cargo test --release -p app -- --ignored typing_latency_on_a_large_file (one typed char then the tokens of 60 visible lines and the bracket match, 52k-line TS file of textModel.ts repeated, median per edit under 16 ms). Before the token store (80b459587ac): 5.6 s at line 100, 2.8 s at line 25000, 0.5 s at line 49000. With it: 238 ms, 221 ms, 270 ms, each edit re-pairing all brackets <br> [3 S] syntax.rs:135: no `tokenizeHeuristically`, the viewport is tokenized from the first untrusted line <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, typing with auto-closing, 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), indentation guessing, model decorations with injected text, bracket matching and bracket pair colorization, 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/browser | src/vs/editor | M8 | ported | [3 S] word_wrap.rs:136: a view line starting inside an inlay hint in a smaller font or with the padding box draws the hint's rest at an even share of its drawn width, upstream splits the spans <br> [3 L] syntax.rs:318, :355: incremental bracket tree. Gate: cargo test --release -p app -- --ignored typing_latency_on_a_large_file (one typed char then the tokens of 60 visible lines and the bracket match, 52k-line TS file of textModel.ts repeated, median per edit under 16 ms). Before the token store (80b459587ac): 5.6 s at line 100, 2.8 s at line 25000, 0.5 s at line 49000. With the token store and each line's brackets kept: 16.5 ms, 17.1 ms, 17.7 ms, of which pairing the 78k brackets again 6.5 ms and the indentation folding ranges 7.6 ms (editor/contrib/folding) <br> [3 S] syntax.rs:135: no `tokenizeHeuristically`, the viewport is tokenized from the first untrusted line <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] syntax.rs:318, :355: incremental bracket tree. Gate: cargo test --release -p app -- --ignored typing_latency_on_a_large_file (one typed char then the tokens of 60 visible lines and the bracket match, 52k-line TS file of textModel.ts repeated, median per edit under 16 ms). Before the token store (80b459587ac): 5.6 s at line 100, 2.8 s at line 25000, 0.5 s at line 49000. With the token store and each line's brackets kept: 16.5 ms, 17.1 ms, 17.7 ms, of which pairing the 78k brackets again 6.5 ms and the indentation folding ranges 7.6 ms (editor/contrib/folding) <br> [3 S] syntax.rs:135: no `tokenizeHeuristically`, the viewport is tokenized from the first untrusted line <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, typing with auto-closing, 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), indentation guessing, model decorations with injected text, bracket matching and bracket pair colorization, 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 |
@@ -306,7 +306,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| editor/contrib/editorState | src/vs/editor/contrib | M8 | verified | | `EditorStateCancellationTokenSource` (Value and Position) on explicit formatting with the editor (format.rs `edit_state`), rename's location resolve and input (rename.rs) and Go to Definition and the other symbol navigations (goto_symbol.rs `run_symbol_navigation`), `TextModelCancellationTokenSource` on formatting without the editor and code actions; keybindingCancellation.ts: `editor.cancelOperation` (Escape while `cancellableOperation`) cancels the active editor's latest pending one (workbench/editor_state.rs): cargo test -p app cancel_operation goto_symbol rename format (55) |
| editor/contrib/find | src/vs/editor/contrib | M8 | verified | | multi-line find and replace inputs (Ctrl+Enter, "\r\n" shown as "\n", growth to `flexibleMaxHeight` 118): cargo test -p app the_find_input; search, replace pattern, find state, find model with decorations and the controller's actions (editor/find/): cargo test -p app editor::find (the seed keeps the model EOL: a_multiline_seed_takes_the_model_eol), upstream find, findModel (with `_largeReplaceAll`), findController and replacePattern tests; find widget (workbench/find_widget.rs): cargo test -p app the_find_widget; match, current match, find scope and range highlight decorations (find_line_decorations); find context keys and keybindings, Find with Arguments, Go to Match, palette entries (cargo test -p app the_find_widget, editor_actions_show); find and replace history, persisted query options (cargo test -p app history the_find_widget); minimap and overview ruler find markers (cargo test -p app the_find_widget merged_match_lines); a controller and widget per code editor, open and drawn in every group and diff side, histories shared (workbench/code_editors.rs `bind_find_widget`; cargo test -p app each_group_keeps_its_own_find_widget_and_shares_the_history the_original_side_takes_the_focus_selection_and_find); pixel-check window find (port/results/pixels.md) (port/notes.md milestone 8) `editor.wordSeparators` for whole words and the seed word: cargo test -p app the_word_separators |
| editor/contrib/floatingMenu | src/vs/editor/contrib | M8 | verified | | `FloatingEditorToolbar` (workbench/floating_menu.rs): the primary actions of `MenuId.EditorContent` at the bottom right, run with the model URI, `.single-button` for one action, the toolbar with the first action primary for more; Define Keybinding over the user keybindings.json and the `editor/content` items of extensions with `contribEditorContentMenu` (git's merge and commit message buttons): cargo test -p app floating_menu editor_content; single button styles moved unchanged from the `define-file-widget.png` pair (port/results/keybindings-editor.md) |
-| editor/contrib/folding | src/vs/editor/contrib | M8 | verified | | folding model, ranges, hidden ranges, indent, marker and syntax range providers, gutter controls, fold/unfold keys with the Cmd+K chords and every folding command by id, per-file state in the editor view state (editor/folding.rs, editor/folding_controller.rs, editor/view_state.rs): cargo test -p app editor::folding (foldingModel, foldingRanges, hiddenRangeModel, indentRangeProvider, syntaxFold tests) folding_and_cursor_keys_run_through_the_keybindings view_state, pixel-check folded |
+| editor/contrib/folding | src/vs/editor/contrib | M8 | ported | [3 M] folding_controller.rs:23: folding.ts computes the ranges in a Delayer (`updateDebounceInfo`, min 200 ms) after an edit; the port per edit, 7.6 ms of the 17 ms per edit in typing_latency_on_a_large_file | folding model, ranges, hidden ranges, indent, marker and syntax range providers, gutter controls, fold/unfold keys with the Cmd+K chords and every folding command by id, per-file state in the editor view state (editor/folding.rs, editor/folding_controller.rs, editor/view_state.rs): cargo test -p app editor::folding (foldingModel, foldingRanges, hiddenRangeModel, indentRangeProvider, syntaxFold tests) folding_and_cursor_keys_run_through_the_keybindings view_state, pixel-check folded |
| editor/contrib/fontZoom | src/vs/editor/contrib | M8 | verified | | `editor/zoom.rs` (EditorZoom, the mouseWheelZoom gesture), `editor.action.fontZoomIn/Out/Reset`, font size and line height scaled in `EditorMetrics` and `Viewport.line_height`: cargo test -p app zoom; ui-pair notes.txt at levels 1, 2 and -1 |
| editor/contrib/format | src/vs/editor/contrib | M13 | verified | | Format Document/Selection/Modified Lines, `_executeFormat*Provider`, format on type (trigger characters, `editor.formatOnType`), Format on Save with `editor.formatOnSaveMode`, edits made minimal by stringDiff (workbench/format.rs, diff string_diff.rs): cargo test -p app format:: (16), cargo test -p diff string_diff; ui-pair Shift+Option+F on a.ts matches the reference (port/notes.md milestone 13) |
| editor/contrib/gotoError | src/vs/editor/contrib | M13 | verified | | workbench/marker_navigation.rs (gotoError.ts, markerNavigationService.ts, gotoErrorWidget.ts): cargo test -p app marker_navigation (the message's 6px scrollbar: a_long_message_scrolls_with_its_6px_scrollbar); Go menu Next/Previous Problem (menus.rs); ui-pair e.ts F8: the widget as in the reference, which has no resize sash either (port/results/language-features.md Go to Next Problem) |
diff --git a/port/notes.md b/port/notes.md
index 7acd0e262e0..d9ab3f81613 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -136,7 +136,8 @@ Done when: the colorize-tests fixtures give the reference's scopes and colors; p
- shortcut: no `semanticTokenColors`; they color semantic tokens, which come with the language features milestone.
- shortcut: no tree-sitter; upstream uses it for TypeScript only behind `editor.experimental.preferTreeSitter.typescript`, off by default.
- Token store (`syntax.rs` `TokenStore`, `syntax/invalid_lines.rs`; textModelTokens.ts `TrackingTokenizationStateStore`, `RangePriorityQueueImpl`, `DefaultBackgroundTokenizer`): each line keeps its tokens and end state; an edit marks its lines untrusted and keeps the old end state of its last line, and tokenizing stops where a new end state equals the old one (`StateStack::equals`, vscode-textmate `StateStackImpl.equals`). A drawn line is tokenized on demand from the first untrusted line; the rest runs in 1 ms chunks after the frame (`workbench/editor_view.rs` `schedule_background_tokenization`), and the bracket pairs are paired again when it is done. Bracket pairing reads the tokens as they are, a line not tokenized yet holds no brackets, as bracketPairsTree.ts does while the background tokenizer runs; it first tokenizes up to 20 untrusted lines so the edited line counts.
-- shortcut: every edit re-pairs every bracket of the document; upstream updates its BracketPairsTree incrementally. Measured by `typing_latency_on_a_large_file`, see the editor/common ledger row.
+- Each line keeps its brackets (`brackets.rs` `line_brackets`) until its text or tokens change, under the drawing theme and under the empty theme `pairs` reads; the theme changing drops them.
+- shortcut: every edit pairs the brackets of all lines again (6.5 ms for 78k brackets); upstream's BracketPairsTree reuses the unchanged nodes. Measured by `typing_latency_on_a_large_file`, see the editor/common ledger row.
- shortcut: `tokenColors` given as a path to a .tmTheme file is not read; no built-in theme uses one.
- shortcut: the theme type reaches the extension host after the eager extensions activate; upstream sends it before `$startExtensionHost`.
- shortcut: no Go to Bracket, Select to Bracket or Force Retokenize commands until keybindings and the command palette land.