|
25 | 25 | import { getLintDiagnostics } from '../../utilities/codemirror/lint'; |
26 | 26 | import { blockTheme } from '../../utilities/codemirror/themes/block'; |
27 | 27 | import { phoenixResources } from '../../utilities/sequence-editor/adaptation-resources'; |
28 | | - import { safeStringify } from '../../utilities/text'; |
29 | 28 | import { showFailureToast, showSuccessToast } from '../../utilities/toast'; |
30 | 29 | import { replaceFileExtension } from '../../utilities/workspaces'; |
31 | 30 | import CssGrid from '../ui/CssGrid.svelte'; |
|
87 | 86 | let commandInfoMapper: CommandInfoMapper; |
88 | 87 | let inputEditorExtension: Extension = []; |
89 | 88 | let outputEditorExtension: Extension = []; |
90 | | - let previousOutputEditorExtension: Extension | null = null; |
91 | 89 | let previousSequenceFilePath: string = sequenceFilePath; |
92 | 90 |
|
93 | 91 | // Debounce only the expensive output format computation, not the state sync |
|
99 | 97 | inputEditorExtension = sequenceAdaptation.input.getEditorExtension(phoenixContext, phoenixResources); |
100 | 98 | } |
101 | 99 |
|
| 100 | + $: if (sequenceAdaptation.outputs.length > 0) { |
| 101 | + selectedOutputFormat = sequenceAdaptation.outputs[0]; |
| 102 | + } |
| 103 | +
|
102 | 104 | $: if (phoenixContext && selectedOutputFormat?.getEditorExtension) { |
103 | 105 | outputEditorExtension = selectedOutputFormat.getEditorExtension(phoenixContext, phoenixResources); |
| 106 | + } else { |
| 107 | + outputEditorExtension = []; |
104 | 108 | } |
105 | 109 |
|
106 | 110 | // insert sequence - use sequenceFilePath as dependency to ensure editor updates when switching files |
|
156 | 160 | editorHeights = '1fr 3px'; |
157 | 161 | } |
158 | 162 |
|
159 | | - $: if (sequenceAdaptation.outputs.length > 0) { |
160 | | - selectedOutputFormat = sequenceAdaptation.outputs[0]; |
161 | | - } |
162 | | -
|
163 | | - $: if ( |
164 | | - showOutputs && |
165 | | - (previousShowOutputs !== showOutputs || |
166 | | - safeStringify(previousOutputEditorExtension) !== safeStringify(outputEditorExtension)) && |
167 | | - editorOutputDiv |
168 | | - ) { |
169 | | - if (safeStringify(previousOutputEditorExtension) !== safeStringify(outputEditorExtension)) { |
170 | | - previousOutputEditorExtension = outputEditorExtension; |
171 | | - } |
| 163 | + $: if (showOutputs && previousShowOutputs !== showOutputs && editorOutputDiv) { |
172 | 164 | if (editorOutputView) { |
173 | 165 | editorOutputView.destroy(); |
174 | 166 | } |
|
186 | 178 | ], |
187 | 179 | parent: editorOutputDiv, |
188 | 180 | }); |
189 | | - debouncedOutputUpdate(editorSequenceView?.state.doc.toString() ?? ''); |
190 | 181 | } |
191 | 182 |
|
192 | 183 | $: updatedSequenceDefinition = sequenceDefinition; |
|
205 | 196 | debouncedOutputUpdate(editorSequenceView?.state.doc.toString() ?? ''); |
206 | 197 | } |
207 | 198 | } |
| 199 | + $: { |
| 200 | + // Reconfigure output editor when adaptation extensions change |
| 201 | + if (editorOutputView) { |
| 202 | + editorOutputView.dispatch({ |
| 203 | + effects: [compartmentOutputAdaptation.reconfigure(outputEditorExtension)], |
| 204 | + }); |
| 205 | + debouncedOutputUpdate(editorSequenceView?.state.doc.toString() ?? ''); |
| 206 | + } |
| 207 | + } |
208 | 208 |
|
209 | 209 | function sequenceUpdateListener(viewUpdate: ViewUpdate): void { |
210 | 210 | const sequence = viewUpdate.state.doc.toString(); |
|
0 commit comments