fixed whitespaces in history
This commit is contained in:
parent
4e2aeca765
commit
71d8f13d08
@ -123,10 +123,12 @@ function outputText(params) {
|
|||||||
tbDiv.removeChild(textIn);
|
tbDiv.removeChild(textIn);
|
||||||
tbDiv.removeChild(textCur);
|
tbDiv.removeChild(textCur);
|
||||||
|
|
||||||
|
let inputSet, whitespaceOnly = false;
|
||||||
if (user !== undefined) {
|
if (user !== undefined) {
|
||||||
// Save input into history if it's not empty
|
// Save input into history if it's not empty
|
||||||
const inputSet = new Set(user.split(''));
|
inputSet = new Set(user.split(''));
|
||||||
if (user !== "" || inputSet.has(" ") && inputSet.size === 1) {
|
whitespaceOnly = inputSet.has(" ") && inputSet.size === 1;
|
||||||
|
if (user !== "" && !whitespaceOnly) {
|
||||||
history.list.push(user);
|
history.list.push(user);
|
||||||
history.index = history.list.length;
|
history.index = history.list.length;
|
||||||
}
|
}
|
||||||
@ -144,7 +146,7 @@ function outputText(params) {
|
|||||||
|
|
||||||
// Run command and return output
|
// Run command and return output
|
||||||
const isUserInput = output === undefined && user !== undefined;
|
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 (commandOutput !== "" && commandOutput !== null) {
|
||||||
// If output is given, display it as text with formatting
|
// If output is given, display it as text with formatting
|
||||||
tbDiv.append(createText(commandOutput, false))
|
tbDiv.append(createText(commandOutput, false))
|
||||||
|
Loading…
Reference in New Issue
Block a user