mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 21:25:47 +01:00
Fully remove formatCode function (trim on script save)
This commit is contained in:
parent
ad5a1c4bac
commit
3c996a47ea
@ -82,7 +82,7 @@ export class Script implements ContentFile {
|
||||
* @param hostname The server to save the script to
|
||||
*/
|
||||
saveScript(filename: ScriptFilePath, code: string, hostname: string): void {
|
||||
this.code = Script.formatCode(code);
|
||||
this.code = code;
|
||||
this.invalidateModule();
|
||||
this.filename = filename;
|
||||
this.server = hostname;
|
||||
@ -129,15 +129,6 @@ export class Script implements ContentFile {
|
||||
static fromJSON(value: IReviverValue): Script {
|
||||
return Generic_fromJSON(Script, value.data, Script.savedKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats code: Removes the starting & trailing whitespace
|
||||
* @param {string} code - The code to format
|
||||
* @returns The formatted code
|
||||
*/
|
||||
static formatCode(code: string): string {
|
||||
return code.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
}
|
||||
|
||||
constructorsForReviver.Script = Script;
|
||||
|
@ -593,9 +593,7 @@ export function Root(props: IProps): React.ReactElement {
|
||||
const openScript = openScripts[index];
|
||||
const serverData = getServerCode(index);
|
||||
if (serverData === null) return " *";
|
||||
// For scripts, server code is stored with its starting & trailing whitespace removed
|
||||
const code = openScript.isTxt ? openScript.code : Script.formatCode(openScript.code);
|
||||
return serverData !== code ? " *" : "";
|
||||
return serverData !== openScript.code ? " *" : "";
|
||||
}
|
||||
function getServerCode(index: number): string | null {
|
||||
const openScript = openScripts[index];
|
||||
|
@ -73,7 +73,7 @@ function convert(code: string): string {
|
||||
out.push(line);
|
||||
}
|
||||
code = out.join("\n");
|
||||
return Script.formatCode(code);
|
||||
return code;
|
||||
}
|
||||
|
||||
export function AwardNFG(n = 1): void {
|
||||
|
Loading…
Reference in New Issue
Block a user