From: Hannu Niemistö Date: Thu, 5 Jan 2017 07:17:47 +0000 (+0200) Subject: Don't add repeated commands to SCL Console command history X-Git-Tag: v1.27.0~37 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=94da9ca73a7b14ae481ea3ec12bdfce272659904;p=simantics%2Fplatform.git Don't add repeated commands to SCL Console command history refs #6939 [PRIVATE-12942] Change-Id: Ic432851620701a53227b0b76c2e2ac74160bfbbe --- diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java index b4260b47b..bd011689f 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/AbstractCommandConsole.java @@ -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( - 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( + commandHistory.subList(COMMAND_HISTORY_SIZE, COMMAND_HISTORY_SIZE*2)); + } commandHistoryPos = commandHistory.size(); // Print it into output area