From a20dd47ec6dd50645916b10d87fb1815c81def88 Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Sun, 2 Jan 2022 02:10:10 +1100 Subject: [PATCH] fixes #2119 close open scripts that exist on deleted servers this prevents a crash by trying to open the script editor with a script open that exists on a server that has been deleted this is achieved by filtering the list of open scripts whenever the editor is opened and removing any that exist on a server that has been deleted it also handles the case of the selected script being one that was removed in which case it defaults to selecting the first script --- src/ScriptEditor/ui/ScriptEditorRoot.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ScriptEditor/ui/ScriptEditorRoot.tsx b/src/ScriptEditor/ui/ScriptEditorRoot.tsx index b2cc86304..09b31d1d1 100644 --- a/src/ScriptEditor/ui/ScriptEditorRoot.tsx +++ b/src/ScriptEditor/ui/ScriptEditorRoot.tsx @@ -120,6 +120,15 @@ export function Root(props: IProps): React.ReactElement { vim: props.vim || Settings.MonacoVim, }); + // Prevent Crash if script is open on deleted server + openScripts = openScripts.filter((script) => { + return GetServer(script.hostname) !== null; + }) + if (currentScript && (GetServer(currentScript.hostname) === null)) { + currentScript = openScripts[0]; + } + + const [dimensions, setDimensions] = useState({ height: window.innerHeight, width: window.innerWidth,