Skip to content

Commit 4efb006

Browse files
committed
fix SequenceEditor to clear existing diagnostics when switching between languages
1 parent 4009fc2 commit 4efb006

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

e2e-tests/data/sequence-adaptation-minimal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
const minimalInputLanguage = {
1818
fileExtension: '.txt',
1919
name: 'Minimal Test Language',
20-
extension: [],
20+
getEditorExtension: () => {},
2121
};
2222

2323
// Minimal output language
2424
const minimalOutputLanguage = {
2525
fileExtension: '.json',
2626
name: 'JSON Output',
27-
extension: [],
27+
getEditorExtension: () => {},
2828

2929
// Convert output back to input format
3030
toInputFormat: function (output) {
@@ -37,7 +37,7 @@ const minimalOutputLanguage = {
3737
},
3838

3939
// Convert input to output format
40-
toOutputFormat: function (input, context, name) {
40+
toOutputFormat: function (input, _context, name) {
4141
// Uncomment the line below to test runtime errors:
4242
// throw new Error('Intentional adaptation error for testing');
4343

src/components/sequencing/SequenceEditor.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<script lang="ts">
44
import { standardKeymap } from '@codemirror/commands';
55
import { syntaxTree } from '@codemirror/language';
6-
import { lintGutter, openLintPanel } from '@codemirror/lint';
6+
import { lintGutter, openLintPanel, setDiagnostics } from '@codemirror/lint';
77
import { Compartment, EditorSelection, EditorState, Transaction, type Extension } from '@codemirror/state';
88
import { keymap, type ViewUpdate } from '@codemirror/view';
99
import type { SyntaxNode } from '@lezer/common';
@@ -149,6 +149,8 @@
149149
editorSequenceView.dispatch({
150150
effects: [compartmentAdaptation.reconfigure(inputEditorExtension)],
151151
});
152+
// Clear any stale diagnostics
153+
editorSequenceView.dispatch(setDiagnostics(editorSequenceView.state, []));
152154
}
153155
}
154156

0 commit comments

Comments
 (0)