From 17dfdef1eedf8818faf04ad8c40ec8105382d4b7 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Tue, 14 May 2024 08:27:04 -0400 Subject: [PATCH] ensure all typescript source files have models when editor loads --- src/CodeEditor/rx/editor.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/CodeEditor/rx/editor.ts b/src/CodeEditor/rx/editor.ts index 6d814c82d..8ad3df3d4 100644 --- a/src/CodeEditor/rx/editor.ts +++ b/src/CodeEditor/rx/editor.ts @@ -1,3 +1,4 @@ +import { Monaco } from "@/CodeEditor/services/Monaco" import { MonacoATA } from "@/CodeEditor/services/Monaco/ATA" import { File, Workspace } from "@/domain/Workspace" import { themeRx } from "@/rx/theme" @@ -21,8 +22,19 @@ export const editorRx = Rx.family((workspace: Workspace) => { workspaceHandleRx(workspace) ) const el = yield* get.some(element) - const monaco = yield* MonacoATA - const editor = yield* monaco.makeEditorWithATA(el) + const { monaco } = yield* Monaco + const { makeEditorWithATA } = yield* MonacoATA + const editor = yield* makeEditorWithATA(el) + + yield* Effect.forEach(workspace.filePaths, ([file, path]) => { + if (file.language === "typescript") { + const uri = monaco.Uri.parse(path) + if (monaco.editor.getModel(uri) === null) { + monaco.editor.createModel(file.initialContent, file.language, uri) + } + } + return Effect.void + }) get.subscribe( editorThemeRx,