GtkEntryCompletion's prefix calculation is case sensitive.
Submitted by Peter Johanson
Link to original bug (#395964)
Description
I'm doing some work with GtkEntry, and GtkEntryCompletion, and have what seems to be a bug in the behaviour of the inline completion. In particular, the default matching function uses a normalized, case folded string comparison for determining matches, but the prefix detection code in gtk_entry_completion_compute_prefix just uses g_str_has_prefix on the original strings. Here's an example to demonstrate:
completion model has the following two strings in the model: BAM BOOM
Steps:
- User types in "ba".
- The completion dropdown shows only the item "BAM", as this is a match.
- No prefix text is set.
Compared to:
- User types in "BA"
- The completion dropdown shows only the item "BAM", as this is a match.
- No prefix text of "M" is appended, so the entry now reads "BAM".
This may actually be the intended behaviour, maybe not. I can think of two potential fixes if this is deemed a bug:
-
Change gtk_entry_completion_compute_prefix to first normalize and case fold the strings before calling g_str_has_prefix. The downside to this I could see is the case where a user has called gtk_entry_completion_set_match_func with their own function which behaves differently, is case sensitive, etc.
-
Provide new API on GtkEntryCompletion along the lines of gtk_entry_completion_set_prefix_func and the prefix function would be called with a key and a TreeIter, and be expected to calculate and return the prefix for the item. Haven't thought out the details on this, but this seems like the more complete fix.
Thoughts? NOTABUG?
Version: 2.10.x