No empty command execution

This commit is contained in:
Daniel Kluge 2022-06-20 22:46:55 +02:00
parent 6d1d791163
commit 75c7e83324

View File

@ -83,6 +83,10 @@ const REPLInput: NextPage<REPLInputParams> = ({historyCallback, historyClear, in
case e.key === "Enter": { case e.key === "Enter": {
e.preventDefault(); e.preventDefault();
const command = (e.target as HTMLInputElement).value.trim(); const command = (e.target as HTMLInputElement).value.trim();
if (command.length === 0) {
historyCallback(["$"]);
return;
}
if (cmdHistory.at(-1) !== command) setCmdHistory(cmdHistory.concat([command]).splice(0, 100)); if (cmdHistory.at(-1) !== command) setCmdHistory(cmdHistory.concat([command]).splice(0, 100));
clearInput(input); clearInput(input);
setInCmdHistory(-1); setInCmdHistory(-1);