Adium

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14354 closed enhancement (fixed)

Contact list search should treat whitespace-separated words as keywords

Reported by: roju Owned by:
Milestone: Adium 1.5 Component: Adium UI
Version: Severity: normal
Keywords: contact list cl Cc:
Patch Status: Accepted

Description (last modified by Robert)

Summary

When searching for a contact in the contact list, it would be nice if the search would treat different words in the search box as keywords and not as one long string. For example, typing "Jo Do" in the search box should return "John Doe", "Joe Dover", etc. This is how e.g. Blackberries search their contacts, and it can be a convenient way to search quickly if you have many contacts with similar names.

Steps to reproduce

  1. Type part of the first and last name of a contact into the search

Expected results

Contacts whose names partially match the search words treated separately should show up in the contact list.

Actual results

Nobody shows up in the contact list; the search string is searched for literally.

Regression

N/A

Notes

Could be implemented with a small change to the generation of the NSPredicate in AIContactHidingController. Instead of passing the search string raw, you could replace whitespace with '*' (i.e. s/ +/*/g) and change the template to use LIKE instead of CONTAINS.

Attachments (2)

ticket-14354-1.diff (4.2 KB) - added by Paul 10 years ago.
First go at an implementation of keyword searching the contact list.
ticket-14354-2.diff (6.3 KB) - added by Paul 10 years ago.
Updated the patch to address memory management notes by xnyhps on IRC. Added an explanitory comment.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 10 years ago by Robert

Summary: contact list search should treat whitespace seperated words as keywordsContact list search should treat whitespace separated words as keywords

comment:2 Changed 10 years ago by Moses Lei

Summary: Contact list search should treat whitespace separated words as keywordsContact list search should treat whitespace-separated words as keywords

comment:3 Changed 10 years ago by Robert

Description: modified (diff)

I've asked Catfish_Man who was one of those who made the search happen, he likes the idea:

basically it's "separate the search string on spaces, then do a
substring search for each separated word, then take the intersection
of the results"

Would you be in for a patch, roju?

comment:4 Changed 10 years ago by Paul

With the warning that it'd be my first obj-c patch, I'm willing to take a stab at it. Is there a particular branch I should target?

comment:5 Changed 10 years ago by Robert

Cool :)

Yes, that would be 1.5 since 1.4 is in string freeze and such.

Changed 10 years ago by Paul

Attachment: ticket-14354-1.diff added

First go at an implementation of keyword searching the contact list.

Changed 10 years ago by Paul

Attachment: ticket-14354-2.diff added

Updated the patch to address memory management notes by xnyhps on IRC. Added an explanitory comment.

comment:6 Changed 10 years ago by Paul

In ticket-14354-2.diff, I use a CFStringTokenizer to split the search string by word (should support languages with non-English word-break conventions), then I generate a predicate that finds the intersection of all of the individual keywords.

comment:7 Changed 10 years ago by David Smith

The CFStringTokenizer use is a nice touch. I hadn't thought of that :)

comment:8 Changed 10 years ago by Robert

Milestone: Adium 1.5
Patch Status: Accepted
Resolution: fixed
Status: newclosed

Patches reviewed by David (Catfish_Man) and Thijs (xnyphs, sphynx) and tested by Thijs, committed by me: 91b268e34c44 and 4c1ce49f878c.

Thanks, great first patch! :)

comment:9 Changed 10 years ago by Robert Vehse

(In 9c3574b12122) Changelogging, refs #14354.

Note: See TracTickets for help on using tickets.