Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.181
diff -u -Ff -r1.181 form.inc
--- includes/form.inc	7 Mar 2007 17:31:40 -0000	1.181
+++ includes/form.inc	16 Mar 2007 15:27:44 -0000
@@ -1418,6 +1418,9 @@   $class = array('form-text');
   if ($element['#autocomplete_path']) {
     drupal_add_js('misc/autocomplete.js');
     $class[] = 'form-autocomplete';
+    if ($element['#autocomplete_highlight']) {
+      $class[] = 'form-autocomplete-highlight';
+    }
     $extra =  '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], array('absolute' => TRUE))) .'" disabled="disabled" />';
   }
   _form_set_class($element, $class);
Index: misc/autocomplete.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v
retrieving revision 1.17
diff -u -Ff -r1.17 autocomplete.js
--- misc/autocomplete.js	9 Jan 2007 07:31:04 -0000	1.17
+++ misc/autocomplete.js	16 Mar 2007 15:41:42 -0000
@@ -201,10 +201,21 @@     return false;
   // Prepare matches
   var ul = document.createElement('ul');
   var ac = this;
   for (key in matches) {
     var li = document.createElement('li');
+
+    // Highlight the user input in the current match if highlighting is enabled.
+    if ($(this.input).is('.form-autocomplete-highlight') ) {
+      var search = new RegExp('('+this.input.value+')', 'i');
+      var string = matches[key].replace(search, '<strong>$1</strong>');
+    }
+    else {
+      var string = matches[key];
+    }
+
     $(li)
-      .html('<div>'+ matches[key] +'</div>')
+      .html('<div>'+ string +'</div>')
       .mousedown(function () { ac.select(this); })
       .mouseover(function () { ac.highlight(this); })
       .mouseout(function () { ac.unhighlight(this); });
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.194
diff -u -Ff -r1.194 profile.module
--- modules/profile/profile.module	11 Feb 2007 09:30:51 -0000	1.194
+++ modules/profile/profile.module	16 Mar 2007 13:55:38 -0000
@@ -707,11 +707,10 @@  * Callback to allow autocomplete of pro
 function profile_autocomplete($field, $string) {
   if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) {
     $matches = array();
-    $result = db_query_range("SELECT value FROM {profile_values} WHERE fid = %d AND LOWER(value) LIKE LOWER('%s%%') GROUP BY value ORDER BY value ASC", $field, $string, 0, 10);
+    $result = db_query_range("SELECT value FROM {profile_values} WHERE fid = %d AND LOWER(value) LIKE LOWER('%%%s%%') GROUP BY value ORDER BY value ASC", $field, $string, 0, 10);
     while ($data = db_fetch_object($result)) {
       $matches[$data->value] = check_plain($data->value);
     }

     print drupal_to_js($matches);
   }
   exit();
@@ -830,7 +829,7 @@  * Retrieve a pipe delimited string of a
  */
 function profile_admin_settings_autocomplete($string) {
   $matches = array();
-  $result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%s%%')", $string, 0, 10);
+  $result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%%%s%%')", $string, 0, 10);
   while ($data = db_fetch_object($result)) {
     $matches[$data->category] = check_plain($data->category);
   }
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.456
diff -u -Ff -r1.456 system.module
--- modules/system/system.module	15 Mar 2007 15:10:38 -0000	1.456
+++ modules/system/system.module	16 Mar 2007 15:40:52 -0000
@@ -61,7 +61,7 @@   $type['form'] = array('#method' => 'po
   $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
   $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE);
   $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE);
-  $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
+  $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#autocomplete_highlight' => TRUE);
   $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128);
   $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm' => array()));
   $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE);
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.758
diff -u -Ff -r1.758 user.module
--- modules/user/user.module	8 Mar 2007 19:03:48 -0000	1.758
+++ modules/user/user.module	16 Mar 2007 15:44:46 -0000
@@ -2543,7 +2543,7 @@  * Retrieve a pipe delimited string of a
 function user_autocomplete($string = '') {
   $matches = array();
   if ($string) {
-    $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
+    $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", $string, 0, 10);
     while ($user = db_fetch_object($result)) {
       $matches[$user->name] = check_plain($user->name);
    }
