Bug 525380 - Search bar should show drop-down list for contact search when length is 1 with CJK. r=asuth
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 09 Apr 2010 16:52:19 +0900
changeset 5416 1db689c775097ecac246301b8407488646a74b6a
parent 5415 5616df8372c498c662bbde881bc9ef888807ee98
child 5417 ac77cab73bd17c29b56820593ffc0405e8af363a
push idunknown
push userunknown
push dateunknown
reviewersasuth
bugs525380
Bug 525380 - Search bar should show drop-down list for contact search when length is 1 with CJK. r=asuth
mailnews/db/gloda/components/glautocomp.js
--- a/mailnews/db/gloda/components/glautocomp.js
+++ b/mailnews/db/gloda/components/glautocomp.js
@@ -197,18 +197,27 @@ function ContactIdentityCompleter() {
   let contactQuery = Gloda.newQuery(Gloda.NOUN_CONTACT);
   contactQuery.orderBy("-popularity").limit(MAX_POPULAR_CONTACTS);
   this.contactCollection = contactQuery.getCollection(this, null);
   this.contactCollection.becomeExplicit();
 }
 ContactIdentityCompleter.prototype = {
   _popularitySorter: function(a, b){ return b.popularity - a.popularity; },
   complete: function ContactIdentityCompleter_complete(aResult, aString) {
-    if (aString.length < 3)
-      return false;
+    if (aString.length < 3) {
+      // In CJK, first name or last name is sometime used as 1 character only.
+      // So we allow autocompleted search even if 1 character.
+      //
+      // [U+3041 - U+9FFF ... Full-width Katakana, Hiragana
+      //                      and CJK Ideograph
+      // [U+AC00 - U+D7FF ... Hangul
+      // [U+F900 - U+FFDC ... CJK compatibility ideograph
+      if (!aString.match(/[\u3041-\u9fff\uac00-\ud7ff\uf900-\uffdc]/))
+        return false;
+    }
 
     let matches;
     if (this.suffixTree) {
       matches = this.suffixTree.findMatches(aString.toLowerCase());
     }
     else
       matches = [];