EDITOR: Add file URI's to monaco to improve intellisense (#1017)

This commit is contained in:
Shy 2024-01-07 13:13:52 +01:00 committed by GitHub
parent 7e721c144e
commit 68a8427838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

@ -1,5 +1,5 @@
import type { ContentFilePath } from "../../Paths/ContentFile"; import type { ContentFilePath } from "../../Paths/ContentFile";
import { editor, Position } from "monaco-editor"; import monaco, { editor, Position } from "monaco-editor";
type ITextModel = editor.ITextModel; type ITextModel = editor.ITextModel;
@ -24,6 +24,13 @@ export class OpenScript {
} }
regenerateModel(): void { 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}`,
}),
);
} }
} }

@ -191,7 +191,14 @@ function Root(props: IProps): React.ReactElement {
code, code,
props.hostname, props.hostname,
new monaco.Position(0, 0), 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); openScripts.push(newScript);
currentScript = newScript; currentScript = newScript;