From 68a8427838800e162cc0c0528db370851c742c7b Mon Sep 17 00:00:00 2001 From: Shy <48560522+shyguy1412@users.noreply.github.com> Date: Sun, 7 Jan 2024 13:13:52 +0100 Subject: [PATCH] EDITOR: Add file URI's to monaco to improve intellisense (#1017) --- src/ScriptEditor/ui/OpenScript.ts | 11 +++++++++-- src/ScriptEditor/ui/ScriptEditorRoot.tsx | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ScriptEditor/ui/OpenScript.ts b/src/ScriptEditor/ui/OpenScript.ts index 30859c833..22573148a 100644 --- a/src/ScriptEditor/ui/OpenScript.ts +++ b/src/ScriptEditor/ui/OpenScript.ts @@ -1,5 +1,5 @@ import type { ContentFilePath } from "../../Paths/ContentFile"; -import { editor, Position } from "monaco-editor"; +import monaco, { editor, Position } from "monaco-editor"; type ITextModel = editor.ITextModel; @@ -24,6 +24,13 @@ export class OpenScript { } regenerateModel(): void { - this.model = editor.createModel(this.code, this.isTxt ? "plaintext" : "javascript"); + this.model = editor.createModel( + this.code, + this.isTxt ? "plaintext" : "javascript", + monaco.Uri.from({ + scheme: "file", + path: `${this.hostname}/${this.path}`, + }), + ); } } diff --git a/src/ScriptEditor/ui/ScriptEditorRoot.tsx b/src/ScriptEditor/ui/ScriptEditorRoot.tsx index f32a9c443..ccd70042a 100644 --- a/src/ScriptEditor/ui/ScriptEditorRoot.tsx +++ b/src/ScriptEditor/ui/ScriptEditorRoot.tsx @@ -191,7 +191,14 @@ function Root(props: IProps): React.ReactElement { code, props.hostname, new monaco.Position(0, 0), - monaco.editor.createModel(code, filename.endsWith(".txt") ? "plaintext" : "javascript"), + monaco.editor.createModel( + code, + filename.endsWith(".txt") ? "plaintext" : "javascript", + monaco.Uri.from({ + scheme: "file", + path: `${props.hostname}/${filename}`, + }), + ), ); openScripts.push(newScript); currentScript = newScript;