Permalink
Browse files

Prevent empty line to go in command line history

  • Loading branch information...
feragon committed Jun 8, 2016
1 parent aa9fe42 commit b5c1f2e7fd21bcf654f36ad187092cc5dc5b983d
Showing with 21 additions and 22 deletions.
  1. +21 −22 lcUI/widgets/clicommand.cpp
@@ -48,36 +48,34 @@ void CliCommand::onReturnPressed() {
auto text = ui->command->text();
bool isNumber;
_history.push_front(text);
if(_history.size() > _historySize) {
_history.pop_back();
}
auto number = text.toDouble(&isNumber);
if(isNumber) {
enterNumber(number);
}
else if(text.indexOf(";") != -1 || text.indexOf(",") != -1) {
enterCoordinate(text);
}
else {
enterCommand(text);
if(text != "") {
_history.push_front(text);
if (_history.size() > _historySize) {
_history.pop_back();
}
auto number = text.toDouble(&isNumber);
if (isNumber) {
enterNumber(number);
}
else if (text.indexOf(";") != -1 || text.indexOf(",") != -1) {
enterCoordinate(text);
}
else {
enterCommand(text);
}
_historyIndex = -1;
ui->command->clear();
}
_historyIndex = -1;
ui->command->clear();
}
void CliCommand::keyPressEvent(QKeyEvent *event) {
onKeyPressed(event);
}
void CliCommand::enterCommand(QString command) {
if(command == "") {
return;
}
auto completion = _completer->currentCompletion();
if(command.compare(completion, Qt::CaseInsensitive) == 0) {
@@ -134,6 +132,7 @@ void CliCommand::enterNumber(double number) {
void CliCommand::onKeyPressed(QKeyEvent *event) {
switch(event->key()) {
case Qt::Key_Up:
if(_historyIndex + 1 < _history.size()) {
_historyIndex++;
ui->command->setText(_history[_historyIndex]);

0 comments on commit b5c1f2e

Please sign in to comment.