Skip to content

Commit

Permalink
Don't truncate results in location bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mooz committed Aug 15, 2019
1 parent 8660622 commit aaef502
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/TabBrowser/ToolBar/LocationBar/LocationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class LocationBar extends Component {
if (this._completion.canceled) {
return;
}
const NUM_CANDIDATE_MAX = 5;
const suggestionList = this._browser.config.LOCATIONBAR_SUGGESTIONS;
// config.LOCATIONBAR_SUGGESTIONS = [
// "SuggestionTab",
Expand All @@ -74,10 +73,7 @@ class LocationBar extends Component {
const waitAll = this._browser.config.LOCATIONBAR_SUGGESTIONS_SYNCED;
if (waitAll) {
let suggestions = await Promise.all(suggestionTasks);
suggestions = suggestions
.filter(s => !!s)
.map(eachSuggestions => eachSuggestions.slice(0, NUM_CANDIDATE_MAX))
.flat();
suggestions = suggestions.filter(s => !!s).flat();
if (this._completion.canceled) {
return;
}
Expand All @@ -86,25 +82,27 @@ class LocationBar extends Component {
// (TODO) reorder candidates according to sources -> Not needed for usability.
let allSuggestions = [];
suggestionTasks.forEach(task => {
task.then(completedSuggestions => {
if (latestQuery !== query) {
return;
}
if (completedSuggestions) {
allSuggestions = allSuggestions.concat(
completedSuggestions.slice(0, NUM_CANDIDATE_MAX)
task
.then(completedSuggestions => {
if (latestQuery !== query) {
return;
}
if (completedSuggestions) {
allSuggestions = allSuggestions.concat(completedSuggestions);
}
if (this._completion.canceled) {
return;
}
this._completion.setSuggestions(
allSuggestions,
this._completion.suggestionSelected
? this._completion.suggestionIndex
: -1
);
}
if (this._completion.canceled) {
return;
}
this._completion.setSuggestions(
allSuggestions,
this._completion.suggestionSelected
? this._completion.suggestionIndex
: -1
);
});
})
.error(error => {
console.error("Error in suggestion: " + error);
});
});
}
};
Expand Down

0 comments on commit aaef502

Please sign in to comment.