Skip to content

Visual Studio Code, rebuilt in Rust

Rust
5.8 KB
Raw Blame

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

  1. 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.
  2. Read the section of port/notes.md that the row or its milestone names (rg -n '^## ' port/notes.md lists the sections). A decision or a trap there wins over what looks right in the code.
  3. Read the upstream files of the unit in upstream/src/vs. They are the specification, tests included.
  4. Read the document of each area the change touches: README.md, "Change touches, read".
  5. Look for what you need in "Reuse before adding" in the same file before you write a helper.
  6. 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.

  1. 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.
  2. Class 1, stale: prove with a named test that the behavior is already right. Then delete the shortcut: comment the gap points to.
  3. 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".
  4. 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 verified and its evidence cell names the check.
  5. Run bun port/tools/ledger-check.ts. After a status change, run bun port/tools/readme-coverage.ts too: it rewrites the coverage block of README.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

  1. Use upstream's command id. Find where upstream registers it (rg "'<id>'" upstream/src/vs) and read its precondition, its keybinding and its menus.
  2. Register the handler in Workbench::new with app/src/commands.rs::register.
  3. The default keybinding is already there if upstream has one: the tables in app/src/keybindings are generated from the reference by port/tools/default-keybindings. Do not edit them by hand and do not handle the key in an element.
  4. A menu entry is data in app/src/menus.rs, under upstream's menu id, group and order.
  5. A when clause reads context keys. A new key is set in app/src/workbench/keyboard.rs::key_context, under upstream's name, from state that is already computed.
  6. Test it through app/src/commands.rs::execute_command in a #[gpui::test], and through the key when the keybinding has a when clause.

Answer a host call

A MainThreadX.$method that an extension reaches through the vscode API.

  1. Read upstream's src/vs/workbench/api/browser/mainThreadX.ts for the method and extHost.protocol.ts for its types.
  2. Choose the path, as extension-host.md explains, "Host calls the port answers": the session thread for state that needs no window, Blocking for an answer that depends on the document state at that moment, Forwarded for the rest.
  3. Add the arm in app/src/main_thread_commands.rs::route, or in the session for path 1. Replace the method's not_ported arm if it has one, and remove the method from the gaps of its main thread class in the ledger.
  4. Convert positions at the boundary only: chars in the port, UTF-16 units in the host.
  5. Check with port/tools/api-tests: the suite of upstream/extensions/vscode-api-tests that 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.executeCommand from 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

  1. The checks of testing.md, "Before a report or a commit".
  2. 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.
  3. Commit messages follow Conventional Commits, type(scope): subject, with the scopes of git log --oneline -10.
  4. A pull request goes through .agents/skills/pr/SKILL.md. The remote is vsrustium. A worker's branch lands through .agents/skills/port-crew/SKILL.md.
  5. 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"