Fixed bug with empty string adding (PY-3232). rubymine/106.384
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Tue, 5 Apr 2011 06:53:07 +0000 (10:53 +0400)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Tue, 5 Apr 2011 15:57:07 +0000 (19:57 +0400)
platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java

index 0e562906b9d4819d13c732a31b9e3b2fa32bc5ea..385b0bb2d86218dcf61645b64bf6b3cc94b250e6 100644 (file)
@@ -2,6 +2,7 @@ package com.intellij.execution.process;
 
 import com.intellij.ide.ui.UISettings;
 import com.intellij.openapi.util.ModificationTracker;
+import com.intellij.openapi.util.text.StringUtil;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
@@ -21,11 +22,14 @@ public class ConsoleHistoryModel implements ModificationTracker {
   public void addToHistory(final String statement) {
     final int maxHistorySize = getMaxHistorySize();
     synchronized (myHistory) {
-      removeFromHistory(statement);
-      if (myHistory.size() >= maxHistorySize) {
-        myHistory.removeLast();
+      myHistoryCursor = -1;
+      if (!StringUtil.isEmptyOrSpaces(statement)) {
+        removeFromHistory(statement);
+        if (myHistory.size() >= maxHistorySize) {
+          myHistory.removeLast();
+        }
+        myHistory.addFirst(statement);
       }
-      myHistory.addFirst(statement);
     }
   }
 
@@ -36,7 +40,7 @@ public class ConsoleHistoryModel implements ModificationTracker {
   public void removeFromHistory(final String statement) {
     synchronized (myHistory) {
       myModificationTracker++;
-      myHistoryCursor = -1;
+
       myHistory.remove(statement);
     }
   }