Visual Studio Code, rebuilt in Rust
Rust
docs(port): drop the finished multi-instance editor plan (#69)
Artur Rok04e605f4ad3c
diff --git a/port/notes.md b/port/notes.mdindex 1f6ee2e3929..ab453f0223b 100644--- a/port/notes.md+++ b/port/notes.md@@ -856,7 +856,7 @@ Scope as in the M19 Work row of port/ledger.md.- Save conflict editor (textFileSaveErrorHandler.ts): Compare in the "content of the file is newer" message opens `conflictResolution:<path>` (the file on disk in the model's encoding and language, following the file while open) against the model, pinned, labeled "<name> (in file) ↔ <name> (in VSRustium) - Resolve save conflict", with the Info help message (Learn More, Don't Show Again as `neverShowAgain` `learnMoreDirtyWriteError`). `saveConflictResolutionContext` shows the title's "Use your changes and overwrite file contents" (check) and "Discard your changes and revert to file contents" (discard): they close the help messages, save with `ignoreModifiedSince` or revert, open the file's editor and close the conflict editor. A save from the conflict editor that conflicts again shows the help as an error. cargo test -p app compare_opens_the_save_conflict_editor.- Floating comment threads (`comments.thread.experimental.style: floating`; commentThreadFloatingWidget.ts, commentThreadFloatingWidgetLayout.ts, commentThreadConnector.ts): the layout functions and `FloatingWidgetSizeModel` are ported 1:1 with their tests (workbench/comment_thread_floating_layout.rs); the widget (workbench/comment_thread_floating.rs) is laid out before each render, where the content is measured with the window's text system: widths from the label, action, button and comment line text widths, heights from the port's comment constants with body lines wrapped at the widget's width. `layout.left` is kept from the code area's left, not the editor's. The connector is active while the thread's reply input has focus (the port's widget takes no focus itself). The comments scroll as a list (`ListId::CommentThread`, list_scroll.rs: the fading scrollbar and top shadow); a wheel they cannot take goes on to the widget, which scrolls the editor. Range decorations (commentThreadRangeDecorator.ts) draw on every line of a shown thread's range at zIndex 20, a second layer while the pointer is over its widget or its reply has the focus; a floating thread's empty range highlights its line. Comments in diff and multi diff editors, with `FloatingWidgetRoom`: see the diff editors bullet below. The Studio mirror needed `port/tools/fetch-builtin-extensions` again for configuration-editing's 18 (js-debug); extension-tests now runs it.- Comment Escape (workbench/comments.rs `Thread::revealed`): a new empty template shows through `shouldReveal` and stays open on Escape (`workbench.action.hideComment`) in the reference, empty or with text typed, without the confirmation `collapse(true)` asks for with unsubmitted text (`steps-comment-escape-typed.json`; `steps-comment-escape-f1-palette.json`: F1 after Escape opens the palette, so the keybinding hold mode was released). Reading the source, ReviewZoneWidget `show()` sets the thread Expanded and the extension host echoes `collapseState: 1`, so a reached `doCollapse` would hide it; since the dialog never shows, the reference's collapse is not reached. The port keeps such a thread `revealed` (the Expanded echo keeps it; Collapse All and the gutter toggle close it) and its Dismiss Comment does nothing. ui-pair `steps-comment-escape-typed.json`: both keep the "Start discussion" zone with "x" typed. cargo test -p app dismissing_a_new_template_keeps_it_open.-- Comments in diff editors: each side of a diff and of every multi diff file is its own code editor upstream, with its own comments controller, so each asks for its commenting ranges and reserves its comment lane. Floating widgets lay out against a `FloatingHost` (the code area, its scroll and per-line tops), so the normal editor, a diff's hand-drawn original pane and a multi diff file side share one path. A multi diff file side's host spans the whole file and its view is the part the list shows; `FloatingWidgetRoom` adds room after the side's last line (it measures from `getBottomForLineNumber(lineCount)`, so the room never counts itself), stored on `FileDiff.room` and recomputed each layout pass. ui-pair `portComments.openDiff: multi` with the floating style: widget, room fill and comment lanes match. Multi diff files have the 35px `DiffEditorGutter` (Revert Block where the modified side is writable, `diffEditorModifiedWritable`; the revert edits the file's model by URI with undo stops, since no editor is open on it) and the DiffEditorWidget line number lane (`lineNumbersMinChars` 5, `lineDecorationsWidth` 10, where the text editor sets 3 and folding adds 16). ui-pair mp1/mp2 (`steps-comment-diff-multi.json`) against mu1/mf1: line numbers, the split, the code and the floating widget line up. The layout is the default `multiDiffEditor.experimental.variant` `noCards`: 32px headers, 8px `contentBottomPadding`, original line numbers hidden unless `diffEditor.hideOriginalLineNumbers` is false. Opening runs "Initialize first change": without a reveal it activates the first change (modified cursor on its start line, `_goToFile` scrolls the list to the file's top) and focuses the editor, so the active file's header takes `list.inactiveSelectionBackground` and its toolbar shows. ui-pair mp5 against mf1: AE 15513 (diff) and 24838 (thread), from 43068 and 55350. Since the multi-instance code editor (port/plans/multi-instance-editor.md) each file side is its own `OpenEditor` drawn through `text_area`: the modified side edits in place, the color detector keeps one detector per drawn code editor (`ColorDetector.editors`), and a file that turns dirty without a text editor opens as an inactive pinned tab 800ms later (workbench/text_file_editor_tracker.rs). ui-pair `steps-multi-diff-edit.json` (Studio /tmp/me-medit, one run): typed AE 11900, undone 10447, find 11025 at `-fuzz 10%`; what is left is the reference's TypeScript diagnostics on `a.ts` (red tab label, Problems) and the Explorer selection, outside the multi diff editor.+- Comments in diff editors: each side of a diff and of every multi diff file is its own code editor upstream, with its own comments controller, so each asks for its commenting ranges and reserves its comment lane. Floating widgets lay out against a `FloatingHost` (the code area, its scroll and per-line tops), so the normal editor, a diff's hand-drawn original pane and a multi diff file side share one path. A multi diff file side's host spans the whole file and its view is the part the list shows; `FloatingWidgetRoom` adds room after the side's last line (it measures from `getBottomForLineNumber(lineCount)`, so the room never counts itself), stored on `FileDiff.room` and recomputed each layout pass. ui-pair `portComments.openDiff: multi` with the floating style: widget, room fill and comment lanes match. Multi diff files have the 35px `DiffEditorGutter` (Revert Block where the modified side is writable, `diffEditorModifiedWritable`; the revert edits the file's model by URI with undo stops, since no editor is open on it) and the DiffEditorWidget line number lane (`lineNumbersMinChars` 5, `lineDecorationsWidth` 10, where the text editor sets 3 and folding adds 16). ui-pair mp1/mp2 (`steps-comment-diff-multi.json`) against mu1/mf1: line numbers, the split, the code and the floating widget line up. The layout is the default `multiDiffEditor.experimental.variant` `noCards`: 32px headers, 8px `contentBottomPadding`, original line numbers hidden unless `diffEditor.hideOriginalLineNumbers` is false. Opening runs "Initialize first change": without a reveal it activates the first change (modified cursor on its start line, `_goToFile` scrolls the list to the file's top) and focuses the editor, so the active file's header takes `list.inactiveSelectionBackground` and its toolbar shows. ui-pair mp5 against mf1: AE 15513 (diff) and 24838 (thread), from 43068 and 55350. Since the multi-instance code editor (port/ledger.md, M20) each file side is its own `OpenEditor` drawn through `text_area`: the modified side edits in place, the color detector keeps one detector per drawn code editor (`ColorDetector.editors`), and a file that turns dirty without a text editor opens as an inactive pinned tab 800ms later (workbench/text_file_editor_tracker.rs). ui-pair `steps-multi-diff-edit.json` (Studio /tmp/me-medit, one run): typed AE 11900, undone 10447, find 11025 at `-fuzz 10%`; what is left is the reference's TypeScript diagnostics on `a.ts` (red tab label, Problems) and the Explorer selection, outside the multi diff editor.- Terminal Option keys (CoreBrowserTerminal.ts `_isThirdLevelShift`): with `terminal.integrated.macOptionIsMeta` off, Option without Ctrl or Cmd on a key past keyCode 47 is left to keypress: the key's character is typed, a key without one (F1 to F12) sends nothing and reaches the workbench keybindings, so Alt+F2 opens the Accessible View on the terminal buffer (ui-pair `port/fixtures/terminal/steps-accessible.json` matches, Escape closes it in both). The terminal also lets a resolved keybinding with Cmd through (`event.metaKey`), and chords skip the shell for every key but Escape. cargo test -p app terminal::keys.- Command palette TF-IDF reads `metadata.description` after the label (`getTfIdfChunk`; reference-commands.json now carries it, port/tools/ref-commands). For "focus accessible terminal view" the reference shows Accessible Buffer Go to Next Command, Open Accessible View, Focus on Terminal View, Toggle Tab Key Moves Focus; the port shows the same four in the same order and a fifth, Focus Previous Terminal in Terminal Group (ui-pair `steps-accessible-palette.json`, fifth sweep session). Traced: the port's TF-IDF corpus (`tf_idf` in command_palette.rs, dumped once with a scratch print) has 376 commands; 156 of the reference's palette commands without a `when` or precondition are not in the port (unported commands such as focusPanel, focusActivityBar, closeAllGroups, 51 with "terminal" in the title). A smaller corpus gives "terminal" and "focus" a higher IDF, which lifts the fifth command over the 0.5 threshold. The algorithm matches tfIdf.ts; the order follows once those commands exist.- `files.autoGuessEncoding` and `files.candidateGuessEncodings` (encoding.ts `guessEncodingByBuffer`, `guessEncodingByCandidates`): upstream's jschardet and iconv-lite run in a Bun worker started on the first guess and kept for the process (app/src/encoding_guess.rs, worker.mjs); the file read waits for its answer, only with the setting on. Running the upstream module keeps jschardet (LGPL-2.1) a separate file as VS Code ships it; a Rust port of it would not. Reopen with Encoding guesses with it too (`autoGuessEncoding: true`). cargo test -p app encoding_guess (the encoding.test.ts cases).diff --git a/port/plans/architecture-deepening.md b/port/plans/architecture-deepening.mdindex 82012ac0283..efade0e3d64 100644--- a/port/plans/architecture-deepening.md+++ b/port/plans/architecture-deepening.md@@ -152,7 +152,7 @@ Inside, two flat private lists, one line per feature: reactions to any model (ho## 2. One pass over the editors of every group-**Decided.** The swap stays (`with_group`, 45 sites in 21 files; `activate_group`, 51 in 22; `with_code_editor`): port/plans/multi-instance-editor.md builds on it. This candidate removes only the traversals that differ in reach without saying so.+**Decided.** The swap stays (`with_group`, 45 sites in 21 files; `activate_group`, 51 in 22; `with_code_editor`): the multi-instance code editor (port/ledger.md, M20) builds on it. This candidate removes only the traversals that differ in reach without saying so.**Evidence.** Four traversals exist: `editors.editors`, `EditorGroup::code_editors`, `EditorGroup::all_editors` and `EditorGroup::model`. The pattern `editors.editors.iter().chain(&editors.models)` visits the active group and the models without an editor, and skips the editors of every other group. It caused a data loss bug: a dirty file in an inactive group got no backup and no auto save (fixed on branch `fix/backup-inactive-groups`, tests `in_another_group`).diff --git a/port/plans/multi-instance-editor.md b/port/plans/multi-instance-editor.mddeleted file mode 100644index ca87307c310..00000000000--- a/port/plans/multi-instance-editor.md+++ /dev/null@@ -1,100 +0,0 @@-# Multi-instance code editor--Ledger task: the "M20 multi-instance code editor" row of port/ledger.md's Work table. Upstream every diff side, multi diff file side,-notebook cell and walkthrough snippet is its own `CodeEditorWidget`; commands run in-`ICodeEditorService.getFocusedCodeEditor() || getActiveCodeEditor()` (codeEditorService.ts: a diff editor's modified-editor, a composite editor's `activeCodeEditor`).--## The seam--The port already draws other editor groups by swapping their state into the active group's fields-(`with_group`, `swapped_group_body`, `drawing_inactive`). A code editor instance gets the same treatment one level down.--- Per-instance state stays where it is: an `OpenEditor` (selections, scroll, view zones, folding, word wrap, snippet- session, decorations). A diff side, a notebook cell, a snippet and a multi diff file side each are one `OpenEditor`,- named by its `model_id` (unique in the part).-- `EditorGroup::focused_code_editors: HashMap<tab, instance>` (replaces `stacked_editors`): the code editor of a tab that- has the focus, `activeCodeEditor`. `active()` and `active_mut()` resolve it first, then the old defaults (a diff's- modified editor, a merge's result, the tab). So every command, the cursor, find, suggest and IME keep using- `editors.active()` unchanged, as upstream's commands use the focused code editor.-- The group's viewport is the focused instance's. The others' sizes wait in `EditorGroup::unfocused_viewports` by- instance; `editors.viewport()` reads the focused one, or the drawn one while an unfocused instance draws.-- Focus moves with `Workbench::focus_code_editor(instance)`: the old instance blurs as `editor_widget_blurred` does- (word highlights, suggest, parameter hints, code actions, rename end; no auto save, the editor pane keeps the focus),- the viewports and the text area bounds swap, the pointer moves, the new instance refreshes its highlights, and the- one `editor_focus` handle takes the keyboard. Notebook cells and snippets keep their own focus paths- (`focus_notebook_cell`, `focus_snippet`), which set the pointer.-- Drawing: `text_area` draws any instance. An unfocused one draws inside `EditorGroup::drawing(instance, ..)` (a- `Cell`, as render is `&self`): `active()` and `viewport()` answer for it, and `text_area` treats it like an inactive- group's editor: no focus tracking, no input handler, no overlay widgets, the inactive selection color. Its layout- goes through `with_code_editor` (a real swap, `&mut`) so `editor_laid_out` measures it. Its listeners: a press- focuses it first (capture phase, as an inactive group's guard does), pointer moves do not reach the focused editor,- the wheel scrolls it.--No registry and no events: the pointer is a map entry, focus moves by a direct call, drawing is a scoped override.--## Consumers--1. Notebook cells and Editor Playground snippets: unfocused models draw through `text_area` instead of their lines- only (selections, view zones, decorations), their own wheel.-2. Diff editor original pane, side by side: `original_editor` draws through `text_area` with its own view zones (the- diff's original alignment zones, as the modified editor gets them), the deleted line and char decorations, scroll- synced with the modified editor both ways, read-only (`originalEditable` false). A press focuses it; selection,- copy and find run in it. Inline the original stays the line number strip it is upstream.-3. Multi diff editor: each file gets an original and a modified `OpenEditor` drawn through `text_area` at the part- of the file the list shows (diffEditorItemTemplate.ts `render`: editor height and scroll top from the list), the- modified side editable; edits recompute the file's diff.--## Status--- Done: the focus pointer for the diff editor's original side (`DiffInput.original_focused`, `EditorGroup::focus_diff_side`,- `active_diff_modified_mut`); the pane stays hand drawn, with plain selection and cursor (port/notes.md, Diff editor).-- Done: the drawing seam, workbench/code_editors.rs. Simpler than the design above: no `focused_code_editors` map- (the existing pointers stay: `stacked_editors`, `original_focused`) and no `Cell` viewport. The focused code editor- owns the group's viewport, text area cells and minimap info; the others park theirs by (group, model id).- `editor_group_body` draws, before the tab body, the unfocused ones its body asked for last frame- (`code_editor_area`), each through `text_area` inside `with_code_editor` (`EditorGroup::drawn`: `active()` answers- with it); layout and wheel go through the same swap. Notebook cells and playground snippets draw this way (their- press still goes through the cell's or snippet's cover, which focuses it first). Each text area's element id carries- its model id: two text areas sharing one id shared one hover state and redrew forever.-- Done: a notebook cell's editor takes a wheel it can scroll before the list (`cell_editor_wheel`, capture phase: GPUI- bubbles in reverse paint order, so the list layer painted after the cells would run first in either phase).-- Done: the focused code editor's cursor blinks (`editor_view/cursor_blink.rs`).-- Done: the diff original pane side by side draws through `code_editor_area`: the original editor takes its side's- alignment zones and unchanged region placeholders (`place_original_zones`), its removed line decorations- (`diff_side_of`), and its scroll is synced with the modified one each frame (`sync_diff_scroll`: the side that moved- since the last sync wins). Comment thread zone widgets draw in an unfocused editor too. Inline the original stays the- line number strip.-- Done: multi diff files as `OpenEditor`s per side (`MultiDiffInput::editors`, `focus(file, side)`): the modified side- edits in place, find and suggest run in the focused side, the host gets the file's edit (`send_content_change` takes- the edited code editor), one color detector per drawn code editor (`ColorDetector.editors`).-- Done: cursor blink checked against viewCursors.ts and viewCursors.css (keyframes, 500ms delay, 20 alternate- iterations, flat blink interval, focus restarts it shown); a smooth wheel over an unfocused snippet or group animates- that editor, not the focused one (`a_smooth_wheel_over_an_unfocused_snippet_animates_that_snippet`,- `a_smooth_wheel_over_an_unfocused_group_animates_its_editor`).-- Done: content hover per code editor, in any group. A move over an unfocused one or another group's runs its hover- inside `with_group` and `with_code_editor` (`code_editor_mouse_moved`, hit test `active_editor_text_at`), a move- off it hides that hover; the hover's computation looks its editor up by model id in every group, and- `follow_content_hover_editor` hides it once its editor did not draw it (`the_mouse_over_an_unfocused_cell_shows_its_hover`,- `the_mouse_over_another_groups_editor_shows_its_hover`). A press on an unfocused cell or snippet shares the hit test,- view zones and wrapped segments counted (`a_click_on_a_wrapped_line_of_an_unfocused_cell_places_the_cursor_there`).-- Done: a find widget per code editor (findController.ts: a controller and widget per `CodeEditorWidget`).- `Workbench::find` is the active code editor's; the others park in `CodeEditors::finds` by group and instance (the- group's text editor pane, whose model changes with the tab and restarts a visible find as `onDidChangeModel` does;- a diff's original or modified side; a merge result; a stacked editor by model id). `find_editor_changed` binds it- (`bind_find_widget`) on every path that changes the active code editor: `activate_group`, `with_code_editor`,- `focus_code_editor`, the editors-changed hook and each find action. The histories move with the binding (one per- window); the query options come from workspace storage on each model change. A parked widget whose model another- editor edited finds again once bound (`FindController::edited_elsewhere`, by version id). An unfocused code editor- and another group's editor draw their own widget and find decorations, without tracking the shared focus handles- (`each_group_keeps_its_own_find_widget_and_shares_the_history`, `the_original_side_takes_the_focus_selection_and_find`).-- Done: comment reply and edit inputs are code editors (simpleCommentEditor.ts, commentReply.ts, commentNode.ts). The- input is a `comment`-scheme markdown model (`comments::INPUT_SCHEME`), out of the tabs; `EditorGroup::comment_editor`- is the focused one and `active()` answers with it, so typing, cursor, suggest and find run in it; the tab's own- editor draws unfocused in the group. Features that describe the tab (outline, commenting ranges, title actions,- resource keys) read `pane_editor()`. Host sync sends its document, no text editor (`isSimpleWidget`). Its options:- no glyph margin, line numbers or folding, `scrollBeyondLastLine` false, height from `calculateEditorHeight`- (`an_expanded_thread_shows_a_zone_and_replies_run_the_form_actions`,- `a_comment_switched_to_editing_runs_the_edit_actions`; ui-pair steps-comment-reply-editor.json).-- Deferred (manager, session 87944dab): the notebook cell and playground instance pass, and the ui-pair pairs for the- diff original side.