console: ignore whitespace commands on history, ignore backslash

This commit is contained in:
Alibek Omarov 2022-01-04 02:31:07 +03:00
parent ccf90beb7d
commit 3351ecd754
1 changed files with 10 additions and 3 deletions

View File

@ -207,8 +207,6 @@ Con_ClearTyping
*/ */
void Con_ClearTyping( void ) void Con_ClearTyping( void )
{ {
int i;
Con_ClearField( &con.input ); Con_ClearField( &con.input );
con.input.widthInChars = con.linewidth; con.input.widthInChars = con.linewidth;
@ -1719,12 +1717,21 @@ Con_HistoryAppend
static void Con_HistoryAppend( con_history_t *self, field_t *from ) static void Con_HistoryAppend( con_history_t *self, field_t *from )
{ {
int prevLine = Q_max( 0, self->line - 1 ); int prevLine = Q_max( 0, self->line - 1 );
const char *buf = from->buffer;
// skip backslashes
if( from->buffer[0] == '\\' || from->buffer[1] == '/' )
buf++;
// only if non-empty // only if non-empty
if( !from->buffer[0] ) if( !from->buffer[0] )
return; return;
// if not copy // skip empty commands
if( Q_isspace( buf ))
return;
// if not copy (don't ignore backslashes)
if( !Q_strcmp( from->buffer, self->lines[prevLine % CON_HISTORY].buffer )) if( !Q_strcmp( from->buffer, self->lines[prevLine % CON_HISTORY].buffer ))
return; return;