From ddb4c113234106a12b74d175a00549b9bfd46073 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Sat, 5 Feb 2022 23:44:32 +0100 Subject: [PATCH] Command backlog only when changed, trim commands --- components/REPL/REPLInput.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/REPL/REPLInput.tsx b/components/REPL/REPLInput.tsx index 56bf9c9..3aab380 100644 --- a/components/REPL/REPLInput.tsx +++ b/components/REPL/REPLInput.tsx @@ -50,6 +50,7 @@ const REPLInput: NextPage = ({historyCallback, historyClear, in const currentInput = input.value.toLowerCase(); // Force lowercase input.value = currentInput; + if (currentInput.trim() === "") input.value = ""; if (currentInput.includes(" ")) { // Command already typed @@ -83,8 +84,8 @@ const REPLInput: NextPage = ({historyCallback, historyClear, in if (e.key === "Enter") { e.preventDefault(); - const command = (e.target as HTMLInputElement).value; - setCmdHistory(cmdHistory.concat([command]).splice(0, 100)); + const command = (e.target as HTMLInputElement).value.trim(); + if (cmdHistory.at(-1) !== command) setCmdHistory(cmdHistory.concat([command]).splice(0, 100)); clearInput(input); setInCmdHistory(-1); setCurrentCmd([]);