mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 04:35:46 +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
|
* @param hostname The server to save the script to
|
||||||
*/
|
*/
|
||||||
saveScript(filename: ScriptFilePath, code: string, hostname: string): void {
|
saveScript(filename: ScriptFilePath, code: string, hostname: string): void {
|
||||||
this.code = Script.formatCode(code);
|
this.code = code;
|
||||||
this.invalidateModule();
|
this.invalidateModule();
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.server = hostname;
|
this.server = hostname;
|
||||||
@ -129,15 +129,6 @@ export class Script implements ContentFile {
|
|||||||
static fromJSON(value: IReviverValue): Script {
|
static fromJSON(value: IReviverValue): Script {
|
||||||
return Generic_fromJSON(Script, value.data, Script.savedKeys);
|
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;
|
constructorsForReviver.Script = Script;
|
||||||
|
@ -593,9 +593,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
const openScript = openScripts[index];
|
const openScript = openScripts[index];
|
||||||
const serverData = getServerCode(index);
|
const serverData = getServerCode(index);
|
||||||
if (serverData === null) return " *";
|
if (serverData === null) return " *";
|
||||||
// For scripts, server code is stored with its starting & trailing whitespace removed
|
return serverData !== openScript.code ? " *" : "";
|
||||||
const code = openScript.isTxt ? openScript.code : Script.formatCode(openScript.code);
|
|
||||||
return serverData !== code ? " *" : "";
|
|
||||||
}
|
}
|
||||||
function getServerCode(index: number): string | null {
|
function getServerCode(index: number): string | null {
|
||||||
const openScript = openScripts[index];
|
const openScript = openScripts[index];
|
||||||
|
@ -73,7 +73,7 @@ function convert(code: string): string {
|
|||||||
out.push(line);
|
out.push(line);
|
||||||
}
|
}
|
||||||
code = out.join("\n");
|
code = out.join("\n");
|
||||||
return Script.formatCode(code);
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AwardNFG(n = 1): void {
|
export function AwardNFG(n = 1): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user