Skip to content

Commit

Permalink
Don't save duplicate consecutive commands to history
Browse files Browse the repository at this point in the history
If the entered command is the same as the last command, don't save
it to history.
  • Loading branch information
DanielGibson committed Nov 13, 2012
1 parent 04266ee commit aedc76b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions neo/framework/Console.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit aedc76b

Please sign in to comment.