From d6018dc66a21a1cf3b88a775e8a1b96eba7ac916 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 15 Mar 2025 20:14:43 +0200 Subject: [PATCH] show bookmarked suggestions first --- .../page/navigation/request/suggestion.rs | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/app/browser/window/tab/item/page/navigation/request/suggestion.rs b/src/app/browser/window/tab/item/page/navigation/request/suggestion.rs index a6efc313..bb8883d2 100644 --- a/src/app/browser/window/tab/item/page/navigation/request/suggestion.rs +++ b/src/app/browser/window/tab/item/page/navigation/request/suggestion.rs @@ -170,30 +170,34 @@ impl Suggestion { let list_store = self.list_store.clone(); let profile = self.profile.clone(); gtk::glib::spawn_future_local(async move { - let list_items = gtk::gio::spawn_blocking(move || { - let result = profile - .history - .contains_request(&query, limit) - .into_iter() - .sorted_by(|a, b| Ord::cmp(&b.opened.count, &a.opened.count)); - let mut list_items = Vec::with_capacity(result.len()); - for item in result { - let subtitle = highlight(&item.request, &query); - let title = match item.title { - Some(title) => highlight(&title, &query), - None => subtitle.clone(), - }; - list_items.push(( - title, - subtitle, - profile.bookmark.is_match_request(&item.request), - item.request, - )) - } - list_items - }) - .await - .unwrap(); + let list_items: Vec<(GString, GString, bool, GString)> = + gtk::gio::spawn_blocking(move || { + let result = profile + .history + .contains_request(&query, limit) + .into_iter() + .sorted_by(|a, b| Ord::cmp(&b.opened.count, &a.opened.count)); + let mut list_items = Vec::with_capacity(result.len()); + for item in result { + let subtitle = highlight(&item.request, &query); + let title = match item.title { + Some(title) => highlight(&title, &query), + None => subtitle.clone(), + }; + list_items.push(( + title, + subtitle, + profile.bookmark.is_match_request(&item.request), + item.request, + )) + } + list_items + .into_iter() + .sorted_by(|a, b| Ord::cmp(&b.2, &a.2)) // bookmark first + .collect() + }) + .await + .unwrap(); if list_items.is_empty() { popover.popdown(); } else {