mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
allow json (#1137)
Allow creating .json files. Also added the json language server so syntax highlighting and validation works with the ingame editor
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { ContentFilePath } from "../../Paths/ContentFile";
|
||||
import { editor, Position } from "monaco-editor";
|
||||
import { makeModel } from "./utils";
|
||||
import { hasTextExtension } from "../../Paths/TextFilePath";
|
||||
|
||||
type ITextModel = editor.ITextModel;
|
||||
|
||||
@@ -21,7 +22,7 @@ export class OpenScript {
|
||||
this.hostname = hostname;
|
||||
this.lastPosition = lastPosition;
|
||||
this.model = model;
|
||||
this.isTxt = path.endsWith(".txt");
|
||||
this.isTxt = hasTextExtension(path);
|
||||
}
|
||||
|
||||
regenerateModel(): void {
|
||||
|
||||
@@ -26,7 +26,7 @@ function makeModel(hostname: string, filename: string, code: string) {
|
||||
scheme: "file",
|
||||
path: `${hostname}/${filename}`,
|
||||
});
|
||||
const language = filename.endsWith(".txt") ? "plaintext" : "javascript";
|
||||
const language = filename.endsWith(".txt") ? "plaintext" : filename.endsWith(".json") ? "json" : "javascript";
|
||||
//if somehow a model already exist return it
|
||||
return editor.getModel(uri) ?? editor.createModel(code, language, uri);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user