mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2025-02-01 21:30:57 +00:00
fixed History_SaveCommand incorrectly ignoring certain commands
This commit is contained in:
parent
ac9d10cc97
commit
ed65f40789
1 changed files with 9 additions and 5 deletions
|
@ -3046,7 +3046,7 @@ static int LengthWithoutTrailingWhitespace( const char* s )
|
||||||
int i = (int)strlen(s);
|
int i = (int)strlen(s);
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
if ( s[i] != ' ' && s[i] != '\t' )
|
if ( s[i] != ' ' && s[i] != '\t' )
|
||||||
return i;
|
return i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3062,11 +3062,15 @@ void History_SaveCommand( history_t* history, const field_t* edit )
|
||||||
// argument count and then each argument with a case sensitive comparison,
|
// argument count and then each argument with a case sensitive comparison,
|
||||||
// but there's only one tokenizer data instance...
|
// but there's only one tokenizer data instance...
|
||||||
// Instead, we only ignore the trailing whitespace.
|
// Instead, we only ignore the trailing whitespace.
|
||||||
|
const int lengthCur = LengthWithoutTrailingWhitespace( edit->buffer );
|
||||||
|
if ( lengthCur == 0 ) {
|
||||||
|
history->display = history->next;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const int prevLine = (history->next - 1) % COMMAND_HISTORY;
|
const int prevLine = (history->next - 1) % COMMAND_HISTORY;
|
||||||
const int length1 = LengthWithoutTrailingWhitespace( edit->buffer );
|
const int lengthPrev = LengthWithoutTrailingWhitespace( history->commands[prevLine].buffer );
|
||||||
const int length2 = LengthWithoutTrailingWhitespace( history->commands[prevLine].buffer );
|
if ( lengthCur == lengthPrev && strncmp(edit->buffer, history->commands[prevLine].buffer, lengthCur) == 0 ) {
|
||||||
const int maxLength = min( length1, length2 );
|
|
||||||
if ( maxLength <= 0 || strncmp(edit->buffer, history->commands[prevLine].buffer, maxLength) == 0 ) {
|
|
||||||
history->display = history->next;
|
history->display = history->next;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue