Skip to content

Commit

Permalink
Optimise search rank algorithm (#1421)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmhewitt authored Oct 2, 2020
1 parent af1c753 commit d4465c1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Views/AppListView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,19 @@ namespace AppCenter.Views {
if (name != null && current_search_term != null) {
var name_lower = name.down ();
var term_lower = current_search_term.down ();
if (name_lower.has_prefix (term_lower)) {

var term_position = name_lower.index_of (term_lower);

// App name starts with our search term, highest priority
if (term_position == 0) {
return 2;
} else if (name_lower.contains (term_lower)) {
// App name contains our search term, high priority
} else if (term_position != -1) {
return 1;
}
}

// Otherwise, normal appstream search ranking order
return 0;
}

Expand Down

0 comments on commit d4465c1

Please sign in to comment.