SearchSuggestOracle: Suggest "self" before other users
For query operators that expect a user, matching users are suggested. The suggestion includes "self" if "self" matches what the user has typed. Since "self" is used more frequently to complete queries than actual user names it should appear first in the suggestion list. Otherwise if "owner:sel" is typed and there are many user names starting with "sel" selecting "self" from the suggestion list gets annoying as one always needs to go to the end of the suggestion list. Change-Id: I49253b7219d6776c997fbb49047d870f48b8bf89 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -53,7 +53,6 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
|
||||
if ("self".startsWith(request.getQuery())) {
|
||||
final ArrayList<SuggestOracle.Suggestion> r =
|
||||
new ArrayList<>(response.getSuggestions().size() + 1);
|
||||
r.addAll(response.getSuggestions());
|
||||
r.add(
|
||||
new SuggestOracle.Suggestion() {
|
||||
@Override
|
||||
@@ -66,6 +65,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
|
||||
return "self";
|
||||
}
|
||||
});
|
||||
r.addAll(response.getSuggestions());
|
||||
response.setSuggestions(r);
|
||||
}
|
||||
done.onSuggestionsReady(request, response);
|
||||
|
||||
Reference in New Issue
Block a user