Various bugfix/cleanup (#489)

* parseCommands no longer removes excess whitespace (it was unneeded and also had a bug in it relating to commands that ended in a quote mark)
* more documentation and some variable renaming
* Fix script editor focus bug on navigating to the editor from sidebar
* Fix initialization for lastNodeReset and lastAugReset
This commit is contained in:
Snarling
2023-04-24 15:48:49 -04:00
committed by GitHub
parent 9004b12256
commit 62adaf3006
4 changed files with 31 additions and 26 deletions

View File

@@ -131,12 +131,13 @@ export function Root(props: IProps): React.ReactElement {
GetServer(openScripts[i].hostname) === null && openScripts.splice(i, 1);
}
if (currentScript && GetServer(currentScript.hostname) === null) {
currentScript = openScripts[0];
if (currentScript === undefined) currentScript = null;
currentScript = openScripts[0] ?? null;
}
useEffect(() => {
if (currentScript !== null) {
const tabIndex = currentTabIndex();
if (typeof tabIndex === "number") onTabClick(tabIndex);
updateRAM(currentScript.code);
}
}, []);
@@ -481,13 +482,7 @@ export function Root(props: IProps): React.ReactElement {
}
function currentTabIndex(): number | undefined {
if (currentScript !== null) {
return openScripts.findIndex(
(script) =>
currentScript !== null && script.path === currentScript.path && script.hostname === currentScript.hostname,
);
}
if (currentScript) return openScripts.findIndex((openScript) => currentScript === openScript);
return undefined;
}