Skip to content

Route a JSON .sldd out of the binary editor instead of throwing - #28

Merged
ww-mw merged 1 commit into
mainfrom
fix-24-json-sldd-in-binary-view
Sep 19, 2026
Merged

ww-mw merged 1 commit into
mainfrom
fix-24-json-sldd-in-binary-view

Conversation

@ww-mw

@ww-mw ww-mw commented Sep 19, 2026

Copy link
Copy Markdown
Member

Fixes the error half of #24.

What the customer saw

With a .sldd open, Reopen Editor With… lists three Data Explorer entries, and one of the two named Data Explorer (editable) threw an error when picked.

Root cause

BinarySlddEditorProvider.openCustomDocument called unzipSync unconditionally. A custom editor's selector is a filename glob, and the two .sldd formats — JSON text and compressed-binary zip — are not distinguishable by name, so this writable binary view is offered for every *.sldd, JSON ones included. On a JSON dictionary the unzip threw invalid zip data, before any panel existed:

Error: invalid zip data
  at unzipSync
  at BinarySlddEditorProvider.openCustomDocument

Fix

Guard the unzip, and hand the file back to dataExplorer.binaryView — the default byte-backed view, which already owns the one format-to-editor rule and is what an Explorer double-click goes through.

Routing back to the router rather than deciding "JSON ⇒ the table view" locally is deliberate: a second copy of that rule would get the over-50 MB JSON dictionary wrong. The default view keeps that one read-only on purpose, because the text-backed table cannot resolve it at all.

Verification

New integration test in binarySlddEdit.test.ts, asserting the tab the user actually ends up looking at. It fails on main for the right reason — Error: invalid zip data at BinarySlddEditorProvider.openCustomDocument — and passes here.

  • npm run verify — green (2480 unit tests, typecheck, both bundles, leak check)
  • npm run test:integration — 134 passing, 1 pending, 0 failing
  • No existing test modified

Qualified in real VS Code rather than in the Playwright webview harness: the symptom is editor routing, which the harness (which serves the webview bundle standalone) cannot see, while the integration test drives the real provider and asserts the resulting tab's viewType.

Still open on #24

The menu still lists two entries both named Data Explorer (editable), and picking the text-backed one for a binary .sldd opens a tab VS Code cannot populate (File seems to be binary and cannot be opened as text — our provider is never reached, so it cannot self-correct). That is a naming/contribution decision, captured on the issue with options rather than guessed at here.

"Reopen Editor With…" offers a custom editor for every file its selector's
filename glob matches, and the two .sldd formats are not distinguishable by
name — so the writable binary view is offered for a JSON dictionary too. Its
openCustomDocument unzipped unconditionally, so choosing it threw "invalid zip
data" before any panel existed: an error notification on a file the default
view opens perfectly well (#24).

Guard the unzip and hand the file back to dataExplorer.binaryView, which owns
the one rule that picks an editor from a .sldd's bytes, rather than deciding
"JSON ⇒ the table view" here. That keeps the rule single: a second copy of it
would get the over-the-sync-limit dictionary wrong, which the default view
deliberately keeps read-only because the text-backed table cannot resolve it
at all.

Reported by @anna-poplawski. The remaining half of that report — two menu
entries sharing the name "Data Explorer (editable)" — is a naming decision and
stays open.
@ww-mw
ww-mw merged commit 4025819 into main Sep 19, 2026
1 check passed
@ww-mw
ww-mw deleted the fix-24-json-sldd-in-binary-view branch September 19, 2026 06:31
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.

1 participant