fix: nano does not open root script if cd'd into a dir

This commit is contained in:
Tim Hesse 2022-10-09 14:49:18 +02:00
parent 3c03ac4f18
commit 7121b456f4

@ -150,8 +150,12 @@ export function ls(args: (string | number | boolean)[], server: BaseServer): voi
return Terminal.error(`File is not on this server, connect to ${hostname} and try again`);
}
if (filename.startsWith("/")) filename = filename.slice(1);
// Terminal.getFilepath needs leading slash to correctly work here
if (prefix === "") filename = `/${filename}`;
const filepath = Terminal.getFilepath(`${prefix}${filename}`);
const code = toString(Terminal.getScript(filepath)?.code);
// Terminal.getScript also calls Terminal.getFilepath and therefore also
// needs the given parameter
const code = toString(Terminal.getScript(`${prefix}${filename}`)?.code);
Router.toScriptEditor({ [filepath]: code });
}