Skip to content

Commit ccf4f34

Browse files
committed
Write whole debug cli command to history
Previously the command was being modified in place in order to find the command name. This was happening before saving to the history. Fixes kiibohd#70
1 parent 7b7a558 commit ccf4f34

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Debug/cli/cli.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,12 @@ void CLI_process()
159159
}
160160
else
161161
{
162-
// Only do command-related stuff if there was actually a command
163-
// Avoids clogging command history with blanks
162+
// Add the command to the history
163+
CLI_saveHistory( CLILineBuffer );
164164

165165
// Process the current line buffer
166166
CLI_commandLookup();
167167

168-
// Add the command to the history
169-
CLI_saveHistory( CLILineBuffer );
170-
171168
// Keep the array circular, discarding the older entries
172169
if ( CLIHistoryTail < CLIHistoryHead )
173170
CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize;
@@ -425,6 +422,11 @@ inline void CLI_saveHistory( char *buff )
425422
return;
426423
}
427424

425+
// Don't write empty lines to the history
426+
const char *cursor = buff;
427+
while (*cursor == ' ') { cursor++; } // advance past the leading whitespace
428+
if (*cursor == '\0') { return ; }
429+
428430
// Copy the line to the history
429431
int i;
430432
for (i = 0; i < CLILineBufferCurrent; i++)

0 commit comments

Comments
 (0)