Command backlog only when changed, trim commands
This commit is contained in:
parent
01571c689c
commit
ddb4c11323
@ -50,6 +50,7 @@ const REPLInput: NextPage<REPLInputParams> = ({historyCallback, historyClear, in
|
|||||||
const currentInput = input.value.toLowerCase();
|
const currentInput = input.value.toLowerCase();
|
||||||
// Force lowercase
|
// Force lowercase
|
||||||
input.value = currentInput;
|
input.value = currentInput;
|
||||||
|
if (currentInput.trim() === "") input.value = "";
|
||||||
|
|
||||||
if (currentInput.includes(" ")) {
|
if (currentInput.includes(" ")) {
|
||||||
// Command already typed
|
// Command already typed
|
||||||
@ -83,8 +84,8 @@ const REPLInput: NextPage<REPLInputParams> = ({historyCallback, historyClear, in
|
|||||||
|
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const command = (e.target as HTMLInputElement).value;
|
const command = (e.target as HTMLInputElement).value.trim();
|
||||||
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);
|
||||||
setCurrentCmd([]);
|
setCurrentCmd([]);
|
||||||
|
Loading…
Reference in New Issue
Block a user