Skip to content

feat(webview): open files in extensions' custom editors - #53

Merged
BartvHelvert merged 2 commits into
masterfrom
feat/custom-editors
Nov 4, 2026
Merged

BartvHelvert merged 2 commits into
masterfrom
feat/custom-editors

Conversation

@BartvHelvert

@BartvHelvert BartvHelvert commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Adds custom editors (contributes.customEditors, registerCustomEditorProvider). A file an enabled
extension's custom editor claims by default opens in the extension's page, in place of its other
editors. This works for text editor providers and for editable custom documents, with save, undo
and redo from the page's keys, Save All, and saving on close. Editors with "priority": "option" are
under Open With in the editor tab menu and the Project view. A switcher beside the tabs reopens a
file as text and writes Set Default to workbench.editorAssociations.

In split mode the backend picks a project file's editors, so the client shows a tab that stands in for
the file, as it does for notebooks. Files of a type the IDE would hand to the system, such as PDFs,
get a non-native type and a placeholder editor so that they reach the client at all. This is recorded
in docs/platform-limitations.md. Webview resources now go through a service worker per webview
origin, which caches them by version, so draw.io-sized pages load quickly, including when reopened.

Save As, backups, revert, diffs and moving an editor are not supported. docs/status.md and
docs/workbench-coverage.md list these.

The first commit is a separate refactor. Hosts now run extensions from the extension store, as VS Code
does, instead of copying every installed extension on each host start. A platform package that an
extension installs for itself (CodeLLDB does) is unpacked into the installed extension's directory.
A replaced or uninstalled version is deleted once no running host uses it.

Fixes #52

How it was tested

  • New SplitModeCustomEditorTest (6 tests, split mode, run in WSL under Xvfb): all pass. It covers a
    text editor provider's edit, undo and save; a custom document's undo, redo, save, and save on
    close; Open With from the Project view; the editor switcher and Set Default; a .pdf-named file
    opening in its custom editor; and a draw.io-sized page loading its resources, including on reopen.
    The workbench probe extension gained custom-editor-probe.js for this.
  • New unit tests: CustomEditorContributionsTest, CustomEditorsTest, CustomEditorTypesTest,
    Base64BytesTest, the webview WebviewResourcesTest, and new cases in ExtensionStoreTest and
    ExtensionHostRouterTest.
  • Full gradlew test: 1475 tests, 0 failures, 2 skipped. Most modules' results came from the
    up-to-date check or the build cache, so they are from earlier runs on the same inputs.
  • During development, a temporary UI test (not included) timed opening a diagram with the real
    Draw.io Integration extension; it is not part of this verification.

Checklist

  • Nothing is special-cased for one extension.
  • A new feature has a UI test.
  • No internal, override-only, obsolete or deprecated platform API.
  • docs/ is updated where behaviour changed, docs/status.md especially.
  • Third-party material keeps its notice and is listed in NOTICE.md.

Every host start copied every installed extension into its own storage,
so a platform package an extension installs for itself (CodeLLDB does)
could be unpacked without touching the extension store. rust-analyzer
alone is 38MB, copied on each start.

Hosts now run extensions from the store, as VS Code runs them from its
extensions directory. A platform package is unpacked into the installed
extension's own directory. Uninstalling or replacing a version only
rewrites the registry; the old directory is deleted once no running
host uses it.
Extensions built on custom editors (draw.io, the Hex Editor, image and
SVG previewers) got no answer from MainThreadCustomEditors, so their
files opened as text or were handed to the system.

A file an enabled extension's contributes.customEditors claims by
default now opens in the extension's page, in place of its other
editors. Text editor providers and editable custom documents both work,
with save, undo and redo from the page's keys, Save All, and saving on
close. Editors that open a file only when asked for are under Open
With, and a switcher beside the tabs reopens a file as text and writes
Set Default to workbench.editorAssociations.

In split mode the backend picks a project file's editors, so the client
stands in a tab for the file, as for notebooks. A file of a type the IDE
would hand to the system (PDFs, office documents) is given a non-native
type and a placeholder editor so it reaches the client at all; see
docs/platform-limitations.md.

Webview resources now go through a service worker per webview origin
that caches them by a version the backend gives, so a page as heavy as
draw.io's loads quickly and again when reopened.

Save As, backups, revert, diffs and moving an editor are not supported.

Refs #52
@BartvHelvert
BartvHelvert merged commit b0da520 into master Nov 4, 2026
4 of 6 checks passed
@BartvHelvert
BartvHelvert deleted the feat/custom-editors branch November 4, 2026 22:05
BartvHelvert added a commit that referenced this pull request Nov 5, 2026
All UI tests on one runner, each starting its own backend and client,
outgrew the Windows step's 100 minutes once #53 added six more.

-PuiTestShard=<index>/<count> runs one shard of the test classes,
balanced by @test count, which is most of a test's time; a class stays
whole. CI runs shards 1/2 and 2/2 on each OS. Without the property every
test runs, as before.

Refs #63
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.

Support custom editors (contributes.customEditors)

1 participant