Skip to content

Run explicit formatting in the background - #764

Merged
renkun-ken merged 1 commit into
masterfrom
codex/background-formatting
Sep 15, 2026
Merged

renkun-ken merged 1 commit into
masterfrom
codex/background-formatting

Conversation

@renkun-ken

Copy link
Copy Markdown
Member

Full-document and explicit-selection formatting currently block the server's event loop. Run document, range, and multiple-range formatting in a lazy background worker so other editor requests remain responsive.

  • Snapshot document content and formatting options for each request; preserve custom styles and literate-document boundaries.
  • Cancel work on client cancellation or document changes, and reject stale results after changes, closure, removal, or reopening.
  • Retire cancelled workers and recover for subsequent formatting requests. Keep on-type formatting on its direct path.

The first explicit formatting request includes worker startup time. Custom formatter side effects now occur in the worker.

Validation: installed this branch independently and passed 45 formatting, handler, server-lifecycle, and LSP test cases with 352 assertions. Tests exercise all three request types, changed style options, disk saves, stale results, and live responsiveness/cancellation during a deliberately stalled formatter. Whitespace checks pass.

This PR contains only background formatting and its tests, based directly on master. Supersedes the formatting portion of #762.

Closes #251.

@renkun-ken
renkun-ken merged commit b85fcdf into master Sep 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run formatting in background process

1 participant