浏览代码

Don't save line repetitions in the console's history

Enhex 9 年之前
父节点
当前提交
1736c67487
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      Source/Urho3D/Engine/Console.cpp

+ 9 - 5
Source/Urho3D/Engine/Console.cpp

@@ -344,11 +344,15 @@ void Console::HandleTextFinished(StringHash eventType, VariantMap& eventData)
         SendEvent(E_CONSOLECOMMAND, newEventData);
 #endif
 
-        // Store to history, then clear the lineedit
-        history_.Push(line);
-        if (history_.Size() > historyRows_)
-            history_.Erase(history_.Begin());
-        historyPosition_ = history_.Size();
+        // Make sure the line isn't the same as the last one
+        if (history_.Empty() || line != history_.Back())
+        {
+            // Store to history, then clear the lineedit
+            history_.Push(line);
+            if (history_.Size() > historyRows_)
+                history_.Erase(history_.Begin());
+            historyPosition_ = history_.Size();
+        }
 
         currentRow_.Clear();
         lineEdit_->SetText(currentRow_);