Merge "Merge branch 'stable-2.13'"
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js
index d8121b7..c33f889 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js
@@ -264,15 +264,22 @@
return this._fetchSuggestions(trimmedInput)
.then(function(operators) {
- if (!operators) { return []; }
+ if (!operators || !operators.length) { return []; }
return operators
- // Disallow autocomplete values that exactly match the str.
- .filter(function(operator) {
- return input.indexOf(operator.toLowerCase()) == -1;
- })
// Prioritize results that start with the input.
- .sort(function(operator) {
- return operator.indexOf(trimmedInput);
+ .sort(function(a, b) {
+ var aContains = a.toLowerCase().indexOf(trimmedInput);
+ var bContains = b.toLowerCase().indexOf(trimmedInput);
+ if (aContains === bContains) {
+ return a.localeCompare(b);
+ }
+ if (aContains === -1) {
+ return 1;
+ }
+ if (bContains === -1) {
+ return -1;
+ }
+ return aContains - bContains;
})
// Return only the first {MAX_AUTOCOMPLETE_RESULTS} results.
.slice(0, MAX_AUTOCOMPLETE_RESULTS - 1)
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html
index a6f1817..696efcd 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.html
@@ -112,6 +112,8 @@
sinon.stub(element.$.restAPI, 'getSuggestedGroups', function() {
return Promise.resolve({
Polygerrit: 0,
+ gerrit: 0,
+ gerrittest: 0,
});
});
sinon.stub(element.$.restAPI, 'getSuggestedProjects', function() {
@@ -174,6 +176,15 @@
done();
});
});
+
+ test('Autocomplete doesnt override exact matches to input',
+ function(done) {
+ return element._getSearchSuggestions('ownerin:gerrit')
+ .then(function(suggestions) {
+ assert.equal(suggestions[0].value, 'ownerin:gerrit');
+ done();
+ });
+ });
});
});
</script>
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js
index 6844416..c524f7f 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.js
@@ -163,8 +163,8 @@
};
/**
- * Re-renders the DIV.contentText alement for the given side and range of diff
- * content.
+ * Re-renders the DIV.contentText elements for the given side and range of
+ * diff content.
*/
GrDiffBuilder.prototype._renderContentByRange = function(start, end, side) {
var lines = [];