fixed whitespaces in history

This commit is contained in:
Baipyrus 2023-01-19 13:52:23 +01:00
parent 4e2aeca765
commit 71d8f13d08

View File

@ -123,10 +123,12 @@ function outputText(params) {
tbDiv.removeChild(textIn);
tbDiv.removeChild(textCur);
let inputSet, whitespaceOnly = false;
if (user !== undefined) {
// Save input into history if it's not empty
const inputSet = new Set(user.split(''));
if (user !== "" || inputSet.has(" ") && inputSet.size === 1) {
inputSet = new Set(user.split(''));
whitespaceOnly = inputSet.has(" ") && inputSet.size === 1;
if (user !== "" && !whitespaceOnly) {
history.list.push(user);
history.index = history.list.length;
}
@ -144,7 +146,7 @@ function outputText(params) {
// Run command and return output
const isUserInput = output === undefined && user !== undefined;
let commandOutput = isUserInput ? runCommand(user) : output;
let commandOutput = (isUserInput && !whitespaceOnly) ? runCommand(user) : (output ? output : "");
if (commandOutput !== "" && commandOutput !== null) {
// If output is given, display it as text with formatting
tbDiv.append(createText(commandOutput, false))