Trying to do better but it's hard

This commit is contained in:
2025-10-15 12:42:56 +02:00
parent 1dc9d1114e
commit ea8ecd4b2a
9 changed files with 200 additions and 163 deletions

View File

@ -42,6 +42,7 @@
const lineNumbersCompartment = new Compartment();
const lineWrappingCompartment = new Compartment();
const vimCompartment = new Compartment();
const languageCompartment = new Compartment();
function handleExecute() {
if (!editorView) return;
@ -111,11 +112,13 @@
const initSettings = $editorSettings;
const fileType = mode === 'livecoding' ? 'orc' : 'csd';
editorView = new EditorView({
doc: value,
extensions: [
...baseExtensions,
csoundMode({ fileType: 'csd' }),
languageCompartment.of(csoundMode({ fileType })),
oneDark,
evaluateKeymap,
flashField(),
@ -154,6 +157,15 @@
editorView.dom.style.fontFamily = settings.fontFamily;
});
$effect(() => {
if (!editorView) return;
const fileType = mode === 'livecoding' ? 'orc' : 'csd';
editorView.dispatch({
effects: languageCompartment.reconfigure(csoundMode({ fileType }))
});
});
onDestroy(() => {
if (editorView) {
editorView.destroy();