mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
Merge pull request #2623 from MartinFournier/fix/editor-asterisk
Ignore trailing whitespace for dirty file asterisk
This commit is contained in:
commit
ba2e2e191c
@ -118,7 +118,7 @@ export class Script {
|
|||||||
*/
|
*/
|
||||||
saveScript(player: IPlayer, filename: string, code: string, hostname: string, otherScripts: Script[]): void {
|
saveScript(player: IPlayer, filename: string, code: string, hostname: string, otherScripts: Script[]): void {
|
||||||
// Update code and filename
|
// Update code and filename
|
||||||
this.code = code.replace(/^\s+|\s+$/g, "");
|
this.code = Script.formatCode(this.code);
|
||||||
|
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.server = hostname;
|
this.server = hostname;
|
||||||
@ -158,6 +158,15 @@ export class Script {
|
|||||||
s.rehash();
|
s.rehash();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reviver.constructors.Script = Script;
|
Reviver.constructors.Script = Script;
|
||||||
|
@ -686,7 +686,9 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
const serverScript = server.scripts.find((s) => s.filename === openScript.fileName);
|
const serverScript = server.scripts.find((s) => s.filename === openScript.fileName);
|
||||||
if (serverScript === undefined) return " *";
|
if (serverScript === undefined) return " *";
|
||||||
|
|
||||||
return serverScript.code !== openScript.code ? " *" : "";
|
// The server code is stored with its starting & trailing whitespace removed
|
||||||
|
const openScriptFormatted = Script.formatCode(openScript.code);
|
||||||
|
return serverScript.code !== openScriptFormatted ? " *" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toolbars are roughly 112px:
|
// Toolbars are roughly 112px:
|
||||||
|
Loading…
Reference in New Issue
Block a user