Visual Studio Code, rebuilt in Rust
Rust
Recipes
The steps that are the same in every area, in the order they run. A recipe that belongs to one area is in that area's document, and the table at the end points to it.
Start a task
- Find the unit:
rg -n '^\| workbench/contrib/<name> ' port/ledger/units. Its row has the milestone, the status, the open gaps and the narrowest check. - Read the section of
port/notes.mdthat the row or its milestone names (rg -n '^## ' port/notes.mdlists the sections). A decision or a trap there wins over what looks right in the code. - Read the upstream files of the unit in
upstream/src/vs. They are the specification, tests included. - Read the document of each area the change touches: README.md, "Change touches, read".
- Look for what you need in "Reuse before adding" in the same file before you write a helper.
- Name the check that will fail without your change, before the first edit.
Close a gap
A gap is one entry of a unit's gaps cell: [class size] where: what. port/ledger.md explains the classes under its "Units" heading.
- Class 3, a behavior gap: port upstream's behavior and its test. The test fails without the fix. Run it once without the fix to see it fail.
- Class 1, stale: prove with a named test that the behavior is already right. Then delete the
shortcut:comment the gap points to. - Class 2, a platform limit: do not work around it. It is closed only by a line of the owner in
port/notes.md, "Accepted platform differences". - In the commit that closes the gap, remove the entry from the cell. When the last class 3 gap of a row goes, the row turns
verifiedand its evidence cell names the check. - Run
bun port/tools/ledger-check.ts. After a status change, runbun port/tools/readme-coverage.tstoo: it rewrites the coverage block ofREADME.md.
A new difference you find and do not fix is a new gap entry in the same commit, with a shortcut: comment at the code. A difference with no entry is a bug in the ledger.
Add a command
- Use upstream's command id. Find where upstream registers it (
rg "'<id>'" upstream/src/vs) and read its precondition, its keybinding and its menus. - Register the handler in
Workbench::newwithapp/src/commands.rs::register. - The default keybinding is already there if upstream has one: the tables in
app/src/keybindingsare generated from the reference byport/tools/default-keybindings. Do not edit them by hand and do not handle the key in an element. - A menu entry is data in
app/src/menus.rs, under upstream's menu id, group and order. - A
whenclause reads context keys. A new key is set inapp/src/workbench/keyboard.rs::key_context, under upstream's name, from state that is already computed. - Test it through
app/src/commands.rs::execute_commandin a#[gpui::test], and through the key when the keybinding has awhenclause.
Answer a host call
A MainThreadX.$method that an extension reaches through the vscode API.
- Read upstream's
src/vs/workbench/api/browser/mainThreadX.tsfor the method andextHost.protocol.tsfor its types. - Choose the path, as extension-host.md explains, "Host calls the port answers": the session thread for state that needs no window,
Blockingfor an answer that depends on the document state at that moment,Forwardedfor the rest. - Add the arm in
app/src/main_thread_commands.rs::route, or in the session for path 1. Replace the method'snot_portedarm if it has one, and remove the method from the gaps of its main thread class in the ledger. - Convert positions at the boundary only: chars in the port, UTF-16 units in the host.
- Check with
port/tools/api-tests: the suite ofupstream/extensions/vscode-api-teststhat calls the method.
Hit every surface
A behavior has more than one way in. Before the report, go through the list and say for each line "done", "not applicable" or the gap entry you wrote.
- Keyboard, mouse and touchpad scroll.
- The menu bar, the context menu, the Command Palette, and
vscode.commands.executeCommandfrom an extension. - macOS, Linux and Windows: a per-OS file has a sibling for each OS (platform.md).
- The four theme kinds: dark, light, High Contrast and High Contrast Light.
- A screen reader: role, label and announcement (accessibility.md).
- State after a restart: storage under upstream's key, and what the extension host gets after it restarts.
- An editor in an auxiliary window and in a second editor group.
Ship it
- The checks of testing.md, "Before a report or a commit".
- The ledger row, the gap entries and the documents change in the same commit as the code. After a rename or a move:
bun port/tools/docs-check.ts. - Commit messages follow Conventional Commits,
type(scope): subject, with the scopes ofgit log --oneline -10. - A pull request goes through
.agents/skills/pr/SKILL.md. The remote isvsrustium. A worker's branch lands through.agents/skills/port-crew/SKILL.md. - The report pairs each requirement with the command that proves it and its real result. A number in the report is measured after the last edit.
Recipes in the area documents
| To | Read |
|---|---|
| Add a workbench feature | workbench.md, "Add a workbench feature" |
| Add a setting or a stored key | settings-and-storage.md, "Add a setting or a stored key" |
Add an unsafe block |
memory-safety.md, "Add an unsafe block" |
| Give a new view its accessibility | accessibility.md, "What a new view provides" |
| Measure a hot path | performance.md, "How to measure" |
| Write a workbench test | testing.md, "Workbench tests" |
| Compare with the reference | testing.md, "Comparing with VS Code" |
| Write or change a document | README.md, "Write a document" |