Skip to content

Visual Studio Code, rebuilt in Rust

Rust
10.6 KB
Raw Blame

Documents

ARCHITECTURE.md is the map of the whole project. Read it first. Each file here goes one level deeper into one area, in the same style: what is where, why, the invariants, and what not to do. A file cites code as a path plus a symbol. If a cited path or symbol is gone, bun port/tools/docs-check.ts fails.

The state of the work, per upstream folder, is not here. It is in port/ledger.md and port/ledger/, with the decisions and measurements in port/notes.md. The words the port uses for its own parts are in GLOSSARY.md.

Change touches, read

Find the row of the code you are about to change and read its file before the first edit. A change that crosses two rows reads both.

The change touches Read
A step that is the same in every area: start a task, close a gap, add a command, answer a host call, ship recipes.md
app/src/workbench.rs, app/src/workbench: layout, parts, views, editor groups, keys, commands, context keys, menus, lists workbench.md
app/src/editor.rs, app/src/editor, app/src/syntax.rs, textmate, diff: the model, cursors, edits, tokens, the editor view editor.md
exthost/src, app/src/host_sync.rs, app/src/main_thread_commands.rs, port/patches: the host process, the protocol, a MainThread* method extension-host.md
exthost/src/extension_management.rs, exthost/src/gallery.rs, exthost/src/scan.rs: scan, install, gallery, signatures, built-ins extensions.md
app/src/terminal.rs, app/src/terminal, ghostty_vt: the pty, the screen, shell integration terminal.md
app/src/webview.rs, app/src/webview: the native web view, its messages and resources webviews.md
files, search, app/src/explorer.rs: disk access, watchers, globs, ripgrep files-and-search.md
config, storage, app/src/keybindings, app/src/user_data_profile.rs: settings, storage, profiles, keybinding tables settings-and-storage.md
app/src/debug.rs, app/src/debug: debug sessions, adapters, breakpoints debug.md
app/src/testing.rs, app/src/testing_coverage.rs: test controllers, runs, results, coverage test-explorer.md
app/src/scm.rs, app/src/scm_history.rs: source control providers, the SCM view, quick diff scm.md
app/src/notebook.rs, app/src/notebook: notebook models, kernels, cell editors, outputs notebooks.md
A file named after an OS, a cfg(target_os), app/src/win32.rs, app/src/x11.rs platform.md
unsafe code, FFI, a raw pointer, a Send or Sync impl memory-safety.md
A render, key_context, a list row, tokenization, startup performance.md
A new view, a role or label, focus, an announcement, a High Contrast color accessibility.md
port/tools/package-app, app/src/update.rs, port/product.json, .github/workflows: packages, signing, the update feed packaging.md
Any test, a comparison with the reference, CI testing.md

Reuse before adding

Before you write a helper, look for its home here. Each row is the one place the port already does the thing. A second copy drifts from the first.

Need Home
Theme color by upstream's key app/src/workbench.rs::color, with a fallback app/src/workbench.rs::foreground_or
Mix, fade or parse a color app/src/theme.rs::color_mix, app/src/theme.rs::parse_hex
Codicon or product icon app/src/workbench.rs::icon, with its own style app/src/workbench.rs::styled_icon
File or folder icon app/src/file_icons.rs::file_icon
Scroll state and scrollbar of a list app/src/workbench/list_scroll.rs::ListId, app/src/workbench/list_scroll.rs::list_scroll_layer
Scrollbar on a container that is not a list app/src/workbench/list_scroll.rs::scrollable
List math: reveal, sticky rows, indent guides app/src/list_tree.rs::reveal_scroll_top, app/src/list_tree.rs::sticky_rows, app/src/list_tree.rs::indent_guides
Tree indent and its guides app/src/workbench/explorer_actions.rs::tree_indent, app/src/workbench/tree_guides.rs::tree_guides_in_group
Text input app/src/workbench/input_box_view.rs::InputId, drawn by app/src/workbench/input_box_view.rs::input_text; the model is app/src/input_box.rs::InputBox
Toolbar or action bar item with focus and keys app/src/workbench/action_bar.rs::action_bar_item
Context menu app/src/workbench/context_menu.rs::show_context_menu, from a list of actions app/src/workbench/context_menu.rs::show_context_menu_actions
Hover or tooltip app/src/workbench/hover.rs::hover_target with app/src/workbench/hover.rs::HoverOptions
Label with match highlights app/src/workbench/quick_input_view.rs::highlighted_label
Markdown app/src/markdown.rs::parse, then app/src/workbench/markdown_view.rs::markdown_blocks
Sash and split sizes app/src/workbench/part_grid.rs::sash_highlight, app/src/split_view.rs::SplitView
Draw one part again, or draw again after paint app/src/workbench/part_view.rs::notify_editor_view, app/src/workbench/part_view.rs::redraw_after_frame
Register or run a command app/src/commands.rs::register, app/src/commands.rs::execute_command
Keybinding: parse, label, resolve app/src/keybindings.rs::parse_keybinding, app/src/keybindings.rs::label, app/src/keybindings.rs::Resolver
Context keys and a when clause app/src/workbench/keyboard.rs::key_context, app/src/contextkey.rs::Expr
Menu items of a menu id app/src/menus.rs::menu_actions
Quick pick or input box app/src/quick_input.rs::QuickInput, shown by app/src/workbench/quick_input_view.rs::show_quick_input
Notification app/src/workbench/notifications_view.rs::notify, app/src/workbench/notifications_view.rs::notify_error
Message dialog app/src/dialog.rs::show_message_box
File open or save dialog app/src/workbench/file_dialogs.rs::show_open_dialog, app/src/workbench/file_dialogs.rs::show_save_dialog
Open an editor app/src/workbench.rs::open_file
Open a link or a URI app/src/workbench/opener.rs::open_link
Status bar entry app/src/workbench/status_entries.rs::status_bar_entry
Read or write a setting app/src/workbench/explorer_actions.rs::setting, app/src/workbench/explorer_actions.rs::update_setting (settings-and-storage.md)
Stored UI state storage/src/lib.rs::Storage, under upstream's key and scope
Localized string app/src/nls.rs::localize_in
Call the extension host app/src/host_sync.rs::HostSync (extension-host.md)
Edit text and tell the host app/src/editor/edit.rs::execute_edits, then app/src/workbench/model_events.rs::model_content_changed
Screen reader announcement, sound signal app/src/workbench/accessibility.rs::aria_alert, app/src/workbench/accessibility.rs::aria_status, app/src/workbench/accessibility.rs::play_signal
File operation with upstream's checks and errors files/src/lib.rs::FileSystem (files-and-search.md)
Watch a path files/src/watcher.rs::Watcher
Glob files/src/glob.rs::parse
Parse JSONC, or edit it and keep the comments config/src/json.rs::parse, config/src/json_edit.rs::set_property
URI app/src/uri.rs::Uri
Path label relative to the workspace app/src/quick_input.rs::path_label
Fuzzy match with highlight ranges app/src/filters.rs::matches_fuzzy, app/src/filters.rs::fuzzy_score
Diff of two texts diff/src/lib.rs::compute_diff

No shared home yet: a generic button, a select box, a count badge, text measurement (text_width), the font constants, the UTF-16 helpers and basename each have a copy per feature. Use the copy nearest to your code and do not add one more. Joining the copies is a change of its own, not a side effect of a feature.

Libraries that are not what you know

A model knows the stock library. The port uses a fork, a pin or only a part of it.

Library What differs Read
GPUI gpui-fast, a fork with Retained Mode: a view keeps its last frame until it calls cx.notify(). The crates the port changes are copies in native/vendor/gpui-fast. The port does not use GPUI's actions and keymap. ARCHITECTURE.md, "GPUI as the port uses it"; native/vendor/README.md
Bun The extension host runs on Bun 1.4.5, not Node. Each difference is a patch in port/patches, gated on process.versions.bun. --node is the control. extension-host.md; port/notes.md, "Bun (1.4.5) as the extension host runtime"
libghostty-vt The terminal screen, from a fork of libghostty-rs pinned by commit in native/crates/ghostty_vt/Cargo.toml. It needs Zig 0.17 to build. Its key encoder is not used. terminal.md
Web views No wry. Each OS has its own: WKWebView, WebKitGTK, WebView2. webviews.md
Oniguruma TextMate grammars run on onig, not on the regex crate: the grammars need its syntax. editor.md
SQLite rusqlite, reading and writing upstream's state.vscdb format. settings-and-storage.md

Write a document

  • A document holds what the code cannot show: why, the invariant, the trap, the order of steps. A list of files that ls gives, or a sentence that repeats a function's name, does not belong.
  • Most changes need no change here. Before adding a paragraph, name what the next reader would get wrong without it; if reading the code answers that, leave it out.
  • When a documented decision or constraint changes, rewrite or remove its text. Never append a second account next to the old one.
  • Cite code as a path plus a symbol, as app/src/commands.rs::register. Never a line number: it is wrong after the next edit.
  • No state of the work: status, gaps and "not done yet" go to the ledger (port/ledger.md, port/ledger/), the story of a decision to port/notes.md.
  • No counts of files, lines or tests. They are stale in a week and nothing checks them.
  • One paragraph per source line. Short sentences. 50 to 110 lines for an area.
  • An area document ends with ## Check a change: the narrowest commands that fail on a mistake in the area.
  • A new document gets a row in "Change touches, read". A new shared helper gets a row in "Reuse before adding".
  • Then run bun port/tools/docs-check.ts.