Adium

Opened 9 years ago

Closed 9 years ago

Last modified 9 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: 1.3.10 Severity: normal
Keywords: contact list cl Cc:
Patch Status: Accepted

Description (last modified by Robby)

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 roju 9 years ago.
First go at an implementation of keyword searching the contact list.
ticket-14354-2.diff (6.3 KB) - added by roju 9 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 9 years ago by Robby

  • Summary changed from contact list search should treat whitespace seperated words as keywords to Contact list search should treat whitespace separated words as keywords

comment:2 Changed 9 years ago by paradoxmo

  • Summary changed from Contact list search should treat whitespace separated words as keywords to Contact list search should treat whitespace-separated words as keywords

comment:3 Changed 9 years ago by Robby

  • 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 9 years ago by roju

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 9 years ago by Robby

Cool :)

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

Changed 9 years ago by roju

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

Changed 9 years ago by roju

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

comment:6 Changed 9 years ago by roju

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 9 years ago by Catfish_Man

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

comment:8 Changed 9 years ago by Robby

  • Milestone set to Adium 1.5
  • Patch Status set to Accepted
  • Resolution set to fixed
  • Status changed from new to closed

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 9 years ago by Robert Vehse

(In 9c3574b12122) Changelogging, refs #14354.

Note: See TracTickets for help on using tickets.