# HG changeset patch # User Mads Kiilerich # Date 2016-06-29 16:53:53 # Node ID d6b3839f3c83031add2a21c4d62c0a5af499b5c8 # Parent b2195895bbd727f752df975052004e886bbe16bc 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 diff --git a/kallithea/public/js/base.js b/kallithea/public/js/base.js --- a/kallithea/public/js/base.js +++ b/kallithea/public/js/base.js @@ -1474,13 +1474,13 @@ var branchSort = function(results, conta 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; }