mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #1453 from 12pm/autocomplete_fix
Fix tab autocompletion
This commit is contained in:
commit
ba675ec18f
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue