X-Git-Url: https://git.donarmstrong.com/?p=kiibohd-controller.git;a=blobdiff_plain;f=Debug%2Fcli%2Fcli.c;h=5c83ee64c98ce4bf60a39c01b80d1f76a8110020;hp=149d12d49af22457731942f9d56582c791c1e672;hb=ccf4f34e928afd88ee3dd34e8248ce04d48dad63;hpb=7b7a55899f392ebb7f615fd1801aaaa3dcc3f738 diff --git a/Debug/cli/cli.c b/Debug/cli/cli.c index 149d12d..5c83ee6 100644 --- a/Debug/cli/cli.c +++ b/Debug/cli/cli.c @@ -159,15 +159,12 @@ void CLI_process() } else { - // Only do command-related stuff if there was actually a command - // Avoids clogging command history with blanks + // Add the command to the history + CLI_saveHistory( CLILineBuffer ); // Process the current line buffer CLI_commandLookup(); - // Add the command to the history - CLI_saveHistory( CLILineBuffer ); - // Keep the array circular, discarding the older entries if ( CLIHistoryTail < CLIHistoryHead ) CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize; @@ -425,6 +422,11 @@ inline void CLI_saveHistory( char *buff ) return; } + // Don't write empty lines to the history + const char *cursor = buff; + while (*cursor == ' ') { cursor++; } // advance past the leading whitespace + if (*cursor == '\0') { return ; } + // Copy the line to the history int i; for (i = 0; i < CLILineBufferCurrent; i++)