Merge pull request #1453 from 12pm/autocomplete_fix

Fix tab autocompletion
This commit is contained in:
Dennis Felsing 2019-02-11 17:10:53 +01:00 committed by GitHub
commit ba675ec18f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -2743,16 +2743,19 @@ int str_utf8_comp_nocase_num(const char *a, const char *b, int num)
int code_b;
const char *old_a = a;
if(num <= 0)
return 0;
while(*a && *b)
{
if(a - old_a >= num)
return 0;
code_a = str_utf8_tolower(str_utf8_decode(&a));
code_b = str_utf8_tolower(str_utf8_decode(&b));
if(code_a != code_b)
return code_a - code_b;
if(a - old_a >= num)
return 0;
}
return (unsigned char)*a - (unsigned char)*b;

View file

@ -72,8 +72,8 @@ TEST(Str, Utf8ToLower)
EXPECT_TRUE(str_utf8_comp_nocase(a, b) > 0);
EXPECT_TRUE(str_utf8_comp_nocase(b, a) < 0);
EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 3) == 0);
EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 4) != 0);
EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 5) == 0);
EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 6) != 0);
EXPECT_TRUE(str_utf8_comp_nocase_num("a", "z", 0) == 0);
EXPECT_TRUE(str_utf8_comp_nocase_num("a", "z", 1) != 0);