]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Don't add repeated commands to SCL Console command history 52/252/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Thu, 5 Jan 2017 07:17:47 +0000 (09:17 +0200)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Thu, 5 Jan 2017 07:17:47 +0000 (09:17 +0200)
refs #6939
[PRIVATE-12942]

Change-Id: Ic432851620701a53227b0b76c2e2ac74160bfbbe

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