Bug 344536 - Limit the number of history items displayed the search bar history dropdown, so that some suggestions are always visible. r=gavin

This commit is contained in:
Willian Gustavo Veiga
2013-09-19 08:50:21 -04:00
parent 004c0139a0
commit 25d575b0f4
2 changed files with 15 additions and 2 deletions

View File

@@ -186,6 +186,14 @@ SuggestAutoComplete.prototype = {
*/
_formHistoryTimer: null,
/**
* Maximum number of history items displayed. This is capped at 7
* because the primary consumer (Firefox search bar) displays 10 rows
* by default, and so we want to leave some space for suggestions
* to be visible.
*/
_historyLimit: 7,
/**
* This clears all the per-request state.
*/
@@ -319,7 +327,8 @@ SuggestAutoComplete.prototype = {
if (this._includeFormHistory && this._formHistoryResult &&
(this._formHistoryResult.searchResult ==
Ci.nsIAutoCompleteResult.RESULT_SUCCESS)) {
for (var i = 0; i < this._formHistoryResult.matchCount; ++i) {
var maxHistoryItems = Math.min(this._formHistoryResult.matchCount, this._historyLimit);
for (var i = 0; i < maxHistoryItems; ++i) {
var term = this._formHistoryResult.getValueAt(i);
// we don't want things to appear in both history and suggestions