Commit 3d0e71b7 authored by Christian Hergert's avatar Christian Hergert
Browse files

completion: improve fuzzy matching

This ensures that we match 'E' before 'e' in 'Endianness' if the input
character is 'e'. Otherwise, 'end' won't match and that is not the
expected behavior.

This just takes the earliest of 'E' or 'e' as the match for any character
that has a toupper() variant, at the cost of running additional matches.

This code does need to stay fast, but it seemed fast enough in testing.

Fixes #673
parent a87898ff
......@@ -1664,7 +1664,10 @@ ide_completion_fuzzy_match (const gchar *haystack,
for (; *casefold_needle; casefold_needle = g_utf8_next_char (casefold_needle))
gunichar ch = g_utf8_get_char (casefold_needle);
gunichar chup = g_unichar_toupper (ch);
const gchar *tmp;
const gchar *downtmp;
const gchar *uptmp;
* Note that the following code is not really correct. We want
......@@ -1675,14 +1678,17 @@ ide_completion_fuzzy_match (const gchar *haystack,
* for function names and symbols.
tmp = strchr (haystack, ch);
downtmp = strchr (haystack, ch);
uptmp = strchr (haystack, chup);
if (tmp == NULL)
tmp = strchr (haystack, g_unichar_toupper (ch));
if (tmp == NULL)
return FALSE;
if (downtmp && uptmp)
tmp = MIN (downtmp, uptmp);
else if (downtmp)
tmp = downtmp;
else if (uptmp)
tmp = uptmp;
return FALSE;
* Here we calculate the cost of this character into the score.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment