changeset 5996:d6b3839f3c83

js: in select2 for branches, show early matches first - this will make full branch names show up first, then other prefixes, followed by later matches
author Mads Kiilerich <madski@unity3d.com>
date Wed, 29 Jun 2016 16:53:53 +0200
parents b2195895bbd7
children b313d735d9c8
files kallithea/public/js/base.js
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Wed Jun 29 16:53:26 2016 +0200
+++ b/kallithea/public/js/base.js	Wed Jun 29 16:53:53 2016 +0200
@@ -1474,13 +1474,13 @@
                 return -1;
             }
 
-            // Put prefix matches before matches in the line
+            // Put early (especially prefix) matches before later matches
             var aPos = a.text.toLowerCase().indexOf(query.term.toLowerCase()),
                 bPos = b.text.toLowerCase().indexOf(query.term.toLowerCase());
-            if (aPos === 0 && bPos !== 0) {
+            if (aPos < bPos) {
                 return -1;
             }
-            if (bPos === 0 && aPos !== 0) {
+            if (bPos < aPos) {
                 return 1;
             }