Don't search for "empty" strings
The contact list is only filtered if the search query is not "empty", i.e., contains at least one non-space character. This prevents returning a list of all the contacts. https://bugzilla.gnome.org/show_bug.cgi?id=700729
This commit is contained in:
parent
e841d8a706
commit
86a4ba7786
2 changed files with 15 additions and 1 deletions
|
@ -40,7 +40,7 @@ public class Contacts.ListPane : Frame {
|
||||||
string []? values;
|
string []? values;
|
||||||
string str = filter_entry.get_text ();
|
string str = filter_entry.get_text ();
|
||||||
|
|
||||||
if (str.length == 0)
|
if (Utils.string_is_empty (str))
|
||||||
values = null;
|
values = null;
|
||||||
else {
|
else {
|
||||||
str = Utils.canonicalize_for_search (str);
|
str = Utils.canonicalize_for_search (str);
|
||||||
|
|
|
@ -174,6 +174,20 @@ public class Contacts.Utils : Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns false if the given string contains at least one non-"space"
|
||||||
|
* character.
|
||||||
|
*/
|
||||||
|
public static bool string_is_empty (string str) {
|
||||||
|
unichar c;
|
||||||
|
|
||||||
|
for (int i = 0; str.get_next_char (ref i, out c);) {
|
||||||
|
if (!c.isspace ())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static string canonicalize_for_search (string str) {
|
public static string canonicalize_for_search (string str) {
|
||||||
unowned string s;
|
unowned string s;
|
||||||
var buf = new unichar[18];
|
var buf = new unichar[18];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue