Update CodeViewer to use internal API for completions

- Update CodeViewer component to call `mergeView?.destroy()` before recreating the merge view
- Add a function to update the two editors when values change

[src/lib/components/CodeViewer.svelte]
- Remove commented out code
- Update code to call `mergeView?.destroy()` before recreating the merge view
- Add a function to update the two editors when the values change
This commit is contained in:
Kiril Videlov 2023-02-15 10:14:37 +01:00
parent 29e76aa24c
commit cf34f525bb

View File

@ -14,19 +14,13 @@
onMount(() => (mergeView = create_merge_view(value, newValue)));
onDestroy(() => mergeView?.destroy());
// $: mergeView && update(value, newValue);
$: mergeView && update(value, newValue);
// function update(a: string | null | undefined, b: string | null | undefined): void {
// mergeView.a.setState(create_editor_state(a));
// mergeView.reconfigure({
// collapseUnchanged: { margin: 3, minSize: 3 },
// })
// view.setState(create_editor_state(value));
// mer
// mergeView.setA(create_editor_state(value));
// mergeView.setB(create_editor_state(value));
// TODO
// }
// There may be a more graceful way to update the two editors
function update(a: string, b: string): void {
mergeView?.destroy()
mergeView = create_merge_view(a, b)
}
function create_editor_state(
value: string | null | undefined