From e21fac03f8c689bb10e443239ec08e9ebd428b3b Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 16 Sep 2012 16:21:39 +0200 Subject: [PATCH] Don't save duplicate consecutive commands to history If the entered command is the same as the last command, don't save it to history. --- neo/framework/Console.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/neo/framework/Console.cpp b/neo/framework/Console.cpp index e5dfd854..1b2a5dac 100644 --- a/neo/framework/Console.cpp +++ b/neo/framework/Console.cpp @@ -631,10 +631,17 @@ void idConsoleLocal::KeyDownEvent( int key ) { cmdSystem->BufferCommandText( CMD_EXEC_APPEND, consoleField.GetBuffer() ); // valid command cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "\n" ); - // copy line to history buffer - historyEditLines[nextHistoryLine % COMMAND_HISTORY] = consoleField; - nextHistoryLine++; + // copy line to history buffer, if it isn't the same as the last command + if ( idStr::Cmp( consoleField.GetBuffer(), + historyEditLines[(nextHistoryLine + COMMAND_HISTORY - 1) % COMMAND_HISTORY].GetBuffer()) != 0 ) + { + historyEditLines[nextHistoryLine % COMMAND_HISTORY] = consoleField; + nextHistoryLine++; + } + historyLine = nextHistoryLine; + // clear the next line from old garbage, else the oldest history entry turns up when pressing DOWN + historyEditLines[nextHistoryLine % COMMAND_HISTORY].Clear(); consoleField.Clear(); consoleField.SetWidthInChars( LINE_WIDTH );