Skip to content

Commit

Permalink
ensure all typescript source files have models when editor loads
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 authored and tim-smart committed May 14, 2024
1 parent 4b370e7 commit 17dfdef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/CodeEditor/rx/editor.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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,
Expand Down

0 comments on commit 17dfdef

Please sign in to comment.