@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve typeahead behavior with mixed-case matches

Summary:
Ref T8510. We had two issues with mixed-case result sorting, like typing `@joe` to match user `Joe`.

- The fallback sort was not normalized properly, so "J" could sort after "j". Instead, normalize values for sorting.
- The `prefix_hits` and older `priority_hits` mechanisms were competing destructively. The `prefix_hits` mechanism completely replaces the `priority_hits` mechanism. Instead, use only the `prefix_hits` mechanism.

Test Plan:
- Copied results for "joe" from WMF.
- Hard-coded the controller to return them.
- Searched for `@joe`.
- After patches, first hit is user "Joe".

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8510

Differential Revision: https://secure.phabricator.com/D16826

+28 -43
+23 -23
resources/celerity/map.php
··· 10 10 'conpherence.pkg.css' => 'cea72e09', 11 11 'conpherence.pkg.js' => '6249a1cf', 12 12 'core.pkg.css' => '4fc9469e', 13 - 'core.pkg.js' => '035325a7', 13 + 'core.pkg.js' => '1a77dddf', 14 14 'darkconsole.pkg.js' => 'e7393ebb', 15 15 'differential.pkg.css' => 'a4ba74b5', 16 16 'differential.pkg.js' => '634399e9', ··· 264 264 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', 265 265 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js' => '013ffff9', 266 266 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadPreloadedSource.js' => '54f314a0', 267 - 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js' => 'b25d5444', 267 + 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js' => '0fcf201c', 268 268 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadStaticSource.js' => '6c0e62fa', 269 269 'rsrc/favicons/apple-touch-icon-114x114.png' => '12a24178', 270 270 'rsrc/favicons/apple-touch-icon-120x120.png' => '0d1543c7', ··· 487 487 'rsrc/js/core/KeyboardShortcutManager.js' => '4a021c10', 488 488 'rsrc/js/core/MultirowRowManager.js' => 'b5d57730', 489 489 'rsrc/js/core/Notification.js' => 'ccf1cbf8', 490 - 'rsrc/js/core/Prefab.js' => 'cfd23f37', 490 + 'rsrc/js/core/Prefab.js' => '8d40ae75', 491 491 'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 492 492 'rsrc/js/core/TextAreaUtils.js' => '320810c8', 493 493 'rsrc/js/core/Title.js' => '485aaa6c', ··· 758 758 'javelin-typeahead-normalizer' => 'e6e25838', 759 759 'javelin-typeahead-ondemand-source' => '013ffff9', 760 760 'javelin-typeahead-preloaded-source' => '54f314a0', 761 - 'javelin-typeahead-source' => 'b25d5444', 761 + 'javelin-typeahead-source' => '0fcf201c', 762 762 'javelin-typeahead-static-source' => '6c0e62fa', 763 763 'javelin-uri' => 'c989ade3', 764 764 'javelin-util' => '93cc50d6', ··· 810 810 'phabricator-notification-menu-css' => '1e055865', 811 811 'phabricator-object-selector-css' => '85ee8ce6', 812 812 'phabricator-phtize' => 'd254d646', 813 - 'phabricator-prefab' => 'cfd23f37', 813 + 'phabricator-prefab' => '8d40ae75', 814 814 'phabricator-remarkup-css' => 'cd912f2c', 815 815 'phabricator-search-results-css' => '7dea472c', 816 816 'phabricator-shaped-request' => '7cbe244b', ··· 1013 1013 'javelin-install', 1014 1014 'javelin-util', 1015 1015 ), 1016 + '0fcf201c' => array( 1017 + 'javelin-install', 1018 + 'javelin-util', 1019 + 'javelin-dom', 1020 + 'javelin-typeahead-normalizer', 1021 + ), 1016 1022 '116cf19b' => array( 1017 1023 'javelin-behavior', 1018 1024 'javelin-stratcom', ··· 1652 1658 'javelin-stratcom', 1653 1659 'javelin-install', 1654 1660 ), 1661 + '8d40ae75' => array( 1662 + 'javelin-install', 1663 + 'javelin-util', 1664 + 'javelin-dom', 1665 + 'javelin-typeahead', 1666 + 'javelin-tokenizer', 1667 + 'javelin-typeahead-preloaded-source', 1668 + 'javelin-typeahead-ondemand-source', 1669 + 'javelin-dom', 1670 + 'javelin-stratcom', 1671 + 'javelin-util', 1672 + ), 1655 1673 '8ff5e24c' => array( 1656 1674 'javelin-behavior', 1657 1675 'javelin-stratcom', ··· 1850 1868 'javelin-request', 1851 1869 'phabricator-shaped-request', 1852 1870 ), 1853 - 'b25d5444' => array( 1854 - 'javelin-install', 1855 - 'javelin-util', 1856 - 'javelin-dom', 1857 - 'javelin-typeahead-normalizer', 1858 - ), 1859 1871 'b2b4fbaf' => array( 1860 1872 'javelin-behavior', 1861 1873 'javelin-dom', ··· 1974 1986 'javelin-stratcom', 1975 1987 'javelin-util', 1976 1988 'phabricator-notification-css', 1977 - ), 1978 - 'cfd23f37' => array( 1979 - 'javelin-install', 1980 - 'javelin-util', 1981 - 'javelin-dom', 1982 - 'javelin-typeahead', 1983 - 'javelin-tokenizer', 1984 - 'javelin-typeahead-preloaded-source', 1985 - 'javelin-typeahead-ondemand-source', 1986 - 'javelin-dom', 1987 - 'javelin-stratcom', 1988 - 'javelin-util', 1989 1989 ), 1990 1990 'd0c516d5' => array( 1991 1991 'javelin-behavior',
+3 -3
webroot/rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadSource.js
··· 303 303 } 304 304 305 305 var default_comparator = function(u, v) { 306 - var key_u = u.sort || u.name; 307 - var key_v = v.sort || v.name; 308 - return key_u.localeCompare(key_v); 306 + var key_u = u.sort || u.name; 307 + var key_v = v.sort || v.name; 308 + return key_u.localeCompare(key_v); 309 309 }; 310 310 311 311 var filter_handler = this.getFilterHandler() || function(value, list) {
+2 -17
webroot/rsrc/js/core/Prefab.js
··· 198 198 prefix_hits[item.id] = true; 199 199 } 200 200 201 - for (var jj = 0; jj < tokens.length; jj++) { 202 - if (item.name.indexOf(tokens[jj]) === 0) { 203 - priority_hits[item.id] = true; 204 - } 205 - } 206 - 207 201 if (!item.priority) { 208 202 continue; 209 203 } 210 204 211 205 if (config.username && item.priority == config.username) { 212 206 self_hits[item.id] = true; 213 - } 214 - 215 - for (var hh = 0; hh < tokens.length; hh++) { 216 - if (item.priority.substr(0, tokens[hh].length) == tokens[hh]) { 217 - priority_hits[item.id] = true; 218 - } 219 207 } 220 208 } 221 209 ··· 240 228 } else { 241 229 return 1; 242 230 } 243 - } 244 - 245 - if (priority_hits[u.id] != priority_hits[v.id]) { 246 - return priority_hits[v.id] ? 1 : -1; 247 231 } 248 232 249 233 if (prefix_hits[u.id] != prefix_hits[v.id]) { ··· 347 331 color: fields[11], 348 332 tokenType: fields[12], 349 333 unique: fields[13] || false, 350 - autocomplete: fields[14] 334 + autocomplete: fields[14], 335 + sort: JX.TypeaheadNormalizer.normalize(fields[0]) 351 336 }; 352 337 }, 353 338