Fix editor file handling and add UI improvements

Enable empty code files, normalize paths, mark currentFile as reactive,
and convert editor styles to SCSS
This commit is contained in:
Torsten Dittmann
2025-05-16 18:35:33 +02:00
parent c639739f3b
commit 83ccff6cb0
3 changed files with 7 additions and 6 deletions
+2 -2
View File
@@ -14,7 +14,7 @@
let editorElement: HTMLDivElement;
export function openFile(code: string, path: string) {
if (!code || path.endsWith('/')) return;
if (path.endsWith('/')) return;
const uri = monaco.Uri.parse(path);
const model = monaco.editor.getModel(uri) ?? monaco.editor.createModel(code, null, uri);
model.setValue(code);
@@ -68,7 +68,7 @@
<div class="editor" role="presentation" bind:this={editorElement}></div>
<style>
<style lang="scss">
.editor {
height: 100%;
overflow: hidden;
+1 -1
View File
@@ -17,7 +17,7 @@ class Studio {
terminals = new SvelteMap<symbol, Synapse>();
activeTerminal = $state(this.mainTerminalId);
filesystem: SvelteSet<string> = $state(new SvelteSet());
currentFile: string | null = null;
currentFile: string | null = $state(null);
openFiles: SvelteSet<string> = $state(new SvelteSet());
synapse: Synapse;
editor: monaco.editor.IStandaloneCodeEditor;
@@ -12,11 +12,12 @@
let mainRef: HTMLElement;
studio.synapse.addEventListener('syncWorkDir', ({ message }) => {
if (studio.streaming) return;
if (studio.streaming === false) return;
const { path, content, event } = message.data as SyncWorkDirData;
if (event !== 'add' && event !== 'change') return;
studio.currentFile = path;
instance?.openFile(content, path);
const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
studio.currentFile = normalizedPath;
instance?.openFile(content, normalizedPath);
});
async function openFile(path: string) {