TERMINAL: Allow new lines in terminal when empty (#605)

This commit is contained in:
rqzcho 2023-06-13 21:04:21 +03:00 committed by GitHub
parent c7d05cae58
commit 2537ded3c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -194,12 +194,14 @@ export function TerminalInput(): React.ReactElement {
async function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): Promise<void> { async function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): Promise<void> {
const ref = terminalInput.current; const ref = terminalInput.current;
// Run command. // Run command or insert newline
if (event.key === KEY.ENTER && value !== "") { if (event.key === KEY.ENTER) {
event.preventDefault(); event.preventDefault();
Terminal.print(`[${Player.getCurrentServer().hostname} /${Terminal.cwd()}]> ${value}`); Terminal.print(`[${Player.getCurrentServer().hostname} /${Terminal.cwd()}]> ${value}`);
Terminal.executeCommands(value); if (value) {
saveValue(""); Terminal.executeCommands(value);
saveValue("");
}
return; return;
} }