Skip to content

Commit

Permalink
devtools: use stable sort when sorting completion suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Jun 5, 2016
1 parent d520f0b commit e2c04b3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions resources/unpacked/devtools/front_end/console/DiracPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,13 @@ WebInspector.DiracPromptWithHistory.prototype = {
return;
}

const annotatedCompletions = completions;
annotatedCompletions.sort((a, b) => {
const sortedAnnotatedCompletions = dirac.stableSort(completions, (a, b) => {
return a.title.localeCompare(b.title);
});

this._markAliasedCompletions(annotatedCompletions);
this._markAliasedCompletions(sortedAnnotatedCompletions);

if (!annotatedCompletions.length) {
if (!sortedAnnotatedCompletions.length) {
this.hideSuggestBox();
return;
}
Expand All @@ -562,9 +561,9 @@ WebInspector.DiracPromptWithHistory.prototype = {
this._updateAnchorBox();
const shouldShowForSingleItem = true; // later maybe implement inline completions like in TextPrompt.js
if (dirac._DEBUG_COMPLETIONS) {
console.log("calling SuggestBox.updateSuggestions", this._anchorBox, annotatedCompletions, selectedIndex, shouldShowForSingleItem, this._userEnteredText);
console.log("calling SuggestBox.updateSuggestions", this._anchorBox, sortedAnnotatedCompletions, selectedIndex, shouldShowForSingleItem, this._userEnteredText);
}
this._suggestBox.updateSuggestions(this._anchorBox, annotatedCompletions, selectedIndex, shouldShowForSingleItem, this._userEnteredText);
this._suggestBox.updateSuggestions(this._anchorBox, sortedAnnotatedCompletions, selectedIndex, shouldShowForSingleItem, this._userEnteredText);
}

// here could be implemented inline completions like in TextPrompt.js
Expand Down

0 comments on commit e2c04b3

Please sign in to comment.