File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ++ )
You can’t perform that action at this time.
0 commit comments