Skip to content

Commit e07f8e5

Browse files
committed
feat(vnext): add disposable completion info
1 parent 246fa6f commit e07f8e5

5 files changed

Lines changed: 504 additions & 6 deletions

File tree

docs/vnext/codemirror-adapter.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,29 @@ The adapter installs one coherent `autocompletion` configuration. Additional
4747
sources belong in `autocomplete.externalSources`; consumers should not install
4848
a second independently configured `autocompletion` extension.
4949

50+
Rich completion details are opt-in through
51+
`autocomplete.infoResolver`. The resolver receives the immutable core item and
52+
an `AbortSignal`, and returns a DOM resource with an explicit `destroy`
53+
callback. The adapter aborts pending work and destroys resolved resources when
54+
the selected option, document input, context, regions, or view lifetime
55+
changes. Resolver failures are contained and simply omit the detail panel.
56+
57+
```ts
58+
const support = sqlEditor({
59+
autocomplete: {
60+
infoResolver: async (item, { signal }) => {
61+
const metadata = await loadMetadata(item, { signal });
62+
const dom = document.createElement("div");
63+
const root = createRoot(dom);
64+
root.render(renderMetadata(metadata));
65+
return { dom, destroy: () => root.unmount() };
66+
},
67+
},
68+
initialContext,
69+
service,
70+
});
71+
```
72+
5073
## Atomic inputs
5174

5275
Context and document changes can share one CodeMirror transaction:

0 commit comments

Comments
 (0)