Repository navigation
Host the JSON dictionary editor on view's JSON dictionary engine (6b V3) - #171
Merged
Merged
Conversation
v1.2.4 adds what the JSON dictionary editor needs to move onto view's
JSON dictionary engine, on ./host only: defaultRegistry (the registry
over core's module-level session that getModel, peekModel, findNode and
invalidate answer from) and the DocumentRegistry type, the engine's
trailerAfterDelivery, opened(view) matched by identity, and a table's
own changed. Nothing changes for apps.
The lockfile resolves the tag to its commit, 1059c6f (the ^{} line of
ls-remote), at version 1.2.4, with no integrity field; view's core peer
is still ^1.54.0. viewPin.test.ts moves with it.
SlddTextEditorProvider is now a host over data-explorer-view's JsonEngine, over its TextDocument: the tables' paints, the narrow repaints that keep them in step with every change of the text, every gesture and its queue, the Status column's baseline and the clip mark are the engine's, lifted from this file. What stays is VS Code's end of each hook and what is this extension's own: the TextDocument (its edits are WorkspaceEdits; its undo, redo, dirty state, save, revert, reload and hot-exit backup are VS Code's, as before), the webview, the messages every table answers alike, Location in Text's reveal, and the Add gallery's keybinding. - jsonDocument.ts: the document, the engine with VS Code's end of its hooks: view's defaultRegistry (where this extension's other readers of a uri's tree find it), the TextDocument as its text, the registers, notices, the Usage column and its reposts, the file's stamp and bytes, trailerAfterDelivery, and each table's own changed (the provider's onChanged). One engine per open document, made by its first table and disposed with its last (perDocument.ts), as the module-level document state was. - textDocumentStore.ts: the TextDocument as the engine's text, call for call. One WorkspaceEdit per edit with every patch in order, its ranges taken against the text as it stands, its answer passed through; a subscription of its own per listener, so the listeners keep their order; text, version and dirty read when asked. No reload of its own: VS Code reloads a clean TextDocument itself. - engineTable.ts: jsonRows, with hasTextView; `ready` opening the table is its own flag (readyOpens), apart from awaitRows; and an open's answer is painted once however many readys asked for it, as the newest repaint was the one that landed. - jsonEntryScan.ts, entrySplice.ts, jsonEntrySync.ts and slddFormat.ts were core 1.54.0's code word for word, and are now re-exports of it, so their importers are unchanged. entrySplice's findEntryElementSpan is core's findJsonEntryElementSpan: core's own findEntryElementSpan is the binary dictionary's XML finder. No behaviour changes. Tests that follow the code: messageDispatch's defersRows probe and multiSelectInvariants' engine branch also count openJsonTable; slddParts' "and the file that navigates the part takes the names from core" becomes "and no host file navigates the part: the scan that does is core's"; the binary relay tests pass readyOpens: false; vitest.config excludes jsonDocument.ts from coverage. New: textDocumentStore, perDocument, coreReExports and engineTable's JSON mode.
Review L1. The engine a document's tables share reads and writes the TextDocument it was made for, and a later table reused it whatever TextDocument it was handed. A table that was never closed (a resolve that threw before its panel's dispose was wired) would then hand a later tab an engine over a closed document's text, whose edit ranges would be applied, by uri, to the live document: a wrong write, where the editor's own per-tab reads could only have shown a wrong Status. - perDocument.ts: a held object joins a table only if it `fits`; one that does not is disposed first (with the tables still holding it, whose close then has nothing left to dispose), and the table makes a fresh one. sameOpenDocument: the same TextDocument, still open. - jsonDocument.ts holds each engine with its TextDocument and opens a table only on an engine of that document, open. - SlddTextEditorProvider.ts: the tab's wiring runs in closingOnThrow, so a resolve that throws after its table opened closes it before the throw goes on. The normal path's posts and registrations are unchanged. Tests (perDocument.test.ts, 5 new): an engine of another TextDocument, and of one closed since, gives way to a fresh one, which a stale table's close leaves alone; a throwing resolve leaves nothing held; a resolve that does not throw keeps its table; and the provider opens its table in closingOnThrow, with the dispose wired inside it. Each guard was mutated, and the mutation fails these tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 6b, V3: the JSON dictionary editor becomes a host over view's JSON dictionary engine (
JsonEngine,data-explorer-view/host, view v1.2.4), over its TextDocument. The engine was lifted in 6a from this file at c73da3c, which is unchanged since, up to main. It now does:This extension keeps VS Code's end of each hook and what is its own: the TextDocument (its edits are WorkspaceEdits; its undo, redo, dirty state, save, revert, reload and hot-exit backup are VS Code's own, as before), the webview, the messages every table answers alike, "Location in Text"'s reveal, and the Add gallery's keybinding.
No behaviour change is intended, and none is named. The P4 runners give the same saves as main's V0c run and as V2's, file by file, with the same answers. JSON's undo/redo sweep, which could not undo locally, ran on CI's window and is equal too (below). The screenshot and posted-message A/B is identical. The integration suites are unchanged and pass.
Commits:
./host:defaultRegistryand theDocumentRegistrytype;trailerAfterDelivery;opened(view)matched by identity;changed.perDocument.ts: a held engine is used only while itfits, i.e. it is the same TextDocument and still open (sameOpenDocument). One that does not fit is disposed first, and the table makes a fresh one. A stale table's later close then disposes nothing.closingOnThrow, so a resolve that throws after its table opened closes the table before the throw goes on. The normal path's posts and registrations are unchanged; the diff is a re-indent plus five lines.What moves where
SlddTextEditorProvider.tsgoes from 2,293 lines to 172. It keepsresolveCustomTextEditor: the webview, thetableThemeIcon, the shared messages, the dispatch chain (whose branches now call the engine's table), "Location in Text"'s reveal (showTextDocumentbeside the table, with its "Failed to locate in text" catch), the Add gallery and the navigate wiring.jsonDocument.ts(new) is the document: the engine, with VS Code's end of its hooks.defaultRegistry, where this extension's other readers of a uri's tree find it.textDocumentStore.ts.hubRegisters().annotateDataRows/annotateDataRowsNow.subscribeUsageRepost.fs.statandfs.readFileof the uri, null on a throw.changed(the provider'sonChanged).perDocument.ts): made by its first table, disposed with its last, shared across provider instances. That is the old module-levelopenDocs.textDocumentStore.ts(new, vscode-free) is the TextDocument as the engine's text, call for call:engineTable.ts:jsonRowsjoins the other two setRows builders, withhasTextView: true;readyopening the table becomes its own flag (readyOpens, false for the binary editor), apart fromawaitRows;readys asked for it. Two readys before the first paint lands were answered by the newest repaint alone (wideLanding'superseded').jsonEntryScan.ts,entrySplice.ts,jsonEntrySync.tsandslddFormat.tswere core 1.54.0's code word for word: 0 code lines differ from core'ssrc/edit/files, comments and imports aside.data-explorer-core, so its importers are unchanged until the tests are rehomed in V6: 30-odd unit test files, goldens/views.ts, the bench, two integration suites, extension.ts, the binary providers and structuralEdit.ts.findEntryElementSpanisfindJsonEntryElementSpan as findEntryElementSpan. Core's ownfindEntryElementSpanis the binary dictionary's XML finder, so a plain re-export would have handed every JSON caller the wrong function. A unit test pins the alias.sectionRowIdbuilder, and the model half is not core's.Order differences, none of them observable
onChanged. A wide paint's drain of a Usage link's selection now comes afteronChanged, which is in the engine's trailer. Before, it came just before it (SlddTextEditorProvider.ts:514 and :515 at main). The drain posts only to this table's webview, andonChangedonly to the Property Inspector's (refreshInspector → inspector.refresh). Each webview's own sequence is unchanged.openTextDocument(uri)was this same TextDocument, which the engine holds..then, as V1's MAT open is.beforeRowIdfrominsertEntryRowswhen it is undefined, where both dictionary editors spelled the key (main's :627-633; the binary editor's old 907-911). VS Code serializes a webview message as JSON, so the page never saw the key. No suite reads it. No change.Test changes, and why
The vscode integration suites are unchanged: no file under test-integration/ is touched.
Unit tests (vitest) that read this extension's source follow the code there. Each keeps its name unless said:
test/messageDispatch.test.ts, "SlddTextEditorProvider.ts answers requestChildren only if its payload defers rows". ItsdefersRowsprobe also counts a table of the JSON engine (openJsonTable(), which is planned by JsonView with the same planner as before. The setRows read already followedsetRows: jsonRowsinto engineTable.ts. Still 4 posts, each withdocUri.test/multiSelectInvariants.test.ts, "SlddTextEditorProvider pastes and drops through runTransfer". The engine branch it gained in V2 also coversopenJsonTable(: paste and drop go to the engine's table, which runs view's runTransfer.test/slddParts.test.ts: "and the file that navigates the part takes the names from core" becomes "and no host file navigates the part: the scan that does is core's". jsonEntryScan.ts is now core's scan, re-exported and nothing else. The test asserts exactly that (its code is oneexport { … } from 'data-explorer-core', and itsscanEntriesis core's), and the absence scan beside it is unchanged. This is the change the 6b plan named for V3.test/engineTable.test.ts: the two binary-mode tests passreadyOpens: falsebesideawaitRows: false, becausereadyopening the table is now its own flag. Names and assertions are unchanged.vitest.config.tsaddssrc/host/jsonDocument.tsto the coverage exclude list, because it importsvscode.textDocumentStore.tsandperDocument.tsare vscode-free, so they are measured.Inventory
textDocumentStore.test.ts(7),perDocument.test.ts(3),coreReExports.test.ts(5: each re-export is core's own, and entrySplice's alias is the JSON finder, which finds a JSON entry where core's XML one finds nothing),engineTable.test.ts's JSON mode (3: the paint order with the drain last and the jsonRows keys; two readys, one paint; rows that cannot be delivered), and commit 3's 5 inperDocument.test.ts(an engine of another TextDocument, or of a closed one, gives way to a fresh one; a throwing resolve leaves nothing held; a resolve that does not throw keeps its table; the provider wraps its wiring). The one-paint guard and each L1 guard were mutation-checked.Gate
npm run verify(on df210e4): typecheck (bench included), both builds, 141 files and 2,250 tests, and check:leak.npm run test:integration(with the runners' environment set): 0 failing in either run.editorSaveSweepset: 456 passing, 8 pending.undo…").undonever reaches the test window. Both runs skipped the same 4, run 2 with no other window open. These 4 contracts run on CI's xvfb window, which never locks. On this PR's CI (run 41141193329) all four passed:editor.edititself and undoes withdefault:undo, with no table and no provider. The failed job was re-run once, and attempt 2 passed (458 passing, 10 pending).vsce ls: the same 136 files as main.dist/webviewis byte-identical. The host bundle shrinks by 2,133 B (desktop) and 2,118 B (web), because the duplicates drop out:jsonView.js+21,893 B andjsonEngine.js+1,053 B, against the provider's −13,541 B;P4, through the real editors (#166's runners), on this branch
On this branch's build (the switch on the 1.2.4 tarball, fdbaaa1, whose
dist/is byte-identical to the v1.2.4 tag's, which this branch pins). The output is in/tmp/eb-run-v3(MAT and gestures) and/tmp/eb-run-v3b(plain edits)./tmp/eb-run-v0c-main) and V2's (/tmp/eb-run-v2*)/tmp/eb-run-p4mat/tmp/eb-run-p4c1521/tmp/eb-run-p4c1521"The 700". Against v0c-main and V2, compare-gesture reports "a saved file differs: 700". All 700 are "undo only in the reference" or "redo only in the reference": the JSON undo and redo saves, 350 + 350, which those runs made with the screen on and this run could not ("not run: this host's undo did not reach an editor"). Counted from the case logs, the 700 are exactly those, and no saved, source or binary undo/redo file differs. So there is no differing file to diff by hand. Against p4sldd and p4real the same cases compare EQUAL, because those references never ran the JSON undo/redo either.
The V2 compare's traceback ("sldd gestures vs V2"): compare-gesture.mjs reads the case list from the reference's folder (
select-sldd-gesture.jsonl), which V2's output folder did not hold. With that list copied in (the same file both runs used, identical to v0c-main's), it gives the same 723 cases and the same 700 JSON undo/redo saves only in V2.Re-gate on commit 3 (df210e4), through the real editor, alone (no other VS Code window). The output is in
/tmp/eb-run-v3l1.JSON undo/redo 350 + 350, on CI's window.
workspace.applyEdit, then VS Code'sundo). Let the gesture sweep move across formats and drag #173 fixes the runner (every case tried, one retry).test/fixtures/arch.sldd), set the sweep's environment, and uploaded the saves. Its CI run 41141477830 (Linux, xvfb) is the evidence, in the artifactjson-gesture-sweep.Risks, data loss first, and what holds each
undoPaintor the repair as before. A rename's catalog ranges stay in the same edit, so the rename is still one undo step. Held by jsonRebuildDuringWrite, functionRenameThroughEditors, textDocumentStore.test.ts and P4.hostEdit/paintedWrite(one-shot), and an undo or redo is recognised fromknownEdits. All of it needs every change delivered synchronously, in VS Code's order, with its replacements untouched, one listener per table: that is the adapter's whole job. Held by undoOfTableEdit, undoRepaintsFromModel, jsonDirtyEventRepaint, jsonRenameRepaint, cutPasteUndo, jsonHostEditRepaint and jsonEntryScopedSync (unit), and P4 undo/redo.dirtyis read live off the TextDocument while a change is heard, so it gives the state before the change; the empty change after it carries the new one. Held by jsonBaselineFollowsDisk, twoTabBaseline and dirtyLifecycle (unit).defaultRegistry, where extension.ts's keystroke invalidate, the Property Inspector, the matrix answer and the read-only view's count find them. Held by view Pin core v1.36.7 #58's registry test, closedTabRelease and jsonInspectorRefresh.jsonRows, the trailer after delivery, one paint for two readys, and the order notes above. Held by engineTable.test.ts, the suites' raw posts and the A/B.For later
createRegisters()and deletes the shared copies kept here: structuralEdit, clipboardAction, clipMarks, entryOps, transfer and xmlStructuralEdit.