]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java
Don't add repeated commands to SCL Console command history
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / console / AbstractCommandConsole.java
index b4260b47b4a07ea01fc2ee2d94a363ce3f22bdea..bd011689f4497f080b86ee86121bb543224ae80d 100644 (file)
@@ -426,10 +426,12 @@ public abstract class AbstractCommandConsole extends Composite {
             return;
         
         // Add command to command history
-        commandHistory.add(command);
-        if(commandHistory.size() > COMMAND_HISTORY_SIZE*2)
-            commandHistory = new ArrayList<String>(
-                    commandHistory.subList(COMMAND_HISTORY_SIZE, COMMAND_HISTORY_SIZE*2));
+        if(commandHistory.isEmpty() || !commandHistory.get(commandHistory.size()-1).equals(command)) {
+            commandHistory.add(command);
+            if(commandHistory.size() > COMMAND_HISTORY_SIZE*2)
+                commandHistory = new ArrayList<String>(
+                        commandHistory.subList(COMMAND_HISTORY_SIZE, COMMAND_HISTORY_SIZE*2));
+        }
         commandHistoryPos = commandHistory.size();
         
         // Print it into output area