mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-01-31 13:40:38 +00:00
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.
This commit is contained in:
parent
04266eee5e
commit
aedc76b50e
1 changed files with 10 additions and 3 deletions
|
@ -631,10 +631,17 @@ void idConsoleLocal::KeyDownEvent( int key ) {
|
||||||
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, consoleField.GetBuffer() ); // valid command
|
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, consoleField.GetBuffer() ); // valid command
|
||||||
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "\n" );
|
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "\n" );
|
||||||
|
|
||||||
// copy line to history buffer
|
// copy line to history buffer, if it isn't the same as the last command
|
||||||
historyEditLines[nextHistoryLine % COMMAND_HISTORY] = consoleField;
|
if ( idStr::Cmp( consoleField.GetBuffer(),
|
||||||
nextHistoryLine++;
|
historyEditLines[(nextHistoryLine + COMMAND_HISTORY - 1) % COMMAND_HISTORY].GetBuffer()) != 0 )
|
||||||
|
{
|
||||||
|
historyEditLines[nextHistoryLine % COMMAND_HISTORY] = consoleField;
|
||||||
|
nextHistoryLine++;
|
||||||
|
}
|
||||||
|
|
||||||
historyLine = 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.Clear();
|
||||||
consoleField.SetWidthInChars( LINE_WIDTH );
|
consoleField.SetWidthInChars( LINE_WIDTH );
|
||||||
|
|
Loading…
Reference in a new issue