Updating cosmic_toplevel plugin to check for an exact appid match, falling back to best match instead
This commit is contained in:
parent
87bb6c6064
commit
58a8f2db64
1 changed files with 35 additions and 14 deletions
|
|
@ -21,6 +21,7 @@ use pop_launcher::{
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
use std::time::Instant;
|
||||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||||
|
|
||||||
use self::toplevel_handler::{toplevel_handler, ToplevelAction};
|
use self::toplevel_handler::{toplevel_handler, ToplevelAction};
|
||||||
|
|
@ -194,21 +195,41 @@ impl<W: AsyncWrite + Unpin> App<W> {
|
||||||
.chain(iter::once(info.title.as_str()))
|
.chain(iter::once(info.title.as_str()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
fde::matching::get_best_match(
|
// if there's an exact appid match, use that instead
|
||||||
&window_words,
|
let exact_appid_match = self
|
||||||
&self.desktop_entries,
|
.desktop_entries
|
||||||
fde::matching::MatchAppIdOptions::default(),
|
.iter()
|
||||||
)
|
.find(|de| de.appid == info.app_id);
|
||||||
.and_then(|de| {
|
if exact_appid_match.is_some()
|
||||||
let score =
|
&& fde::matching::get_entry_score(
|
||||||
fde::matching::get_entry_score(&query, de, &self.locales, &window_words);
|
&query,
|
||||||
|
exact_appid_match.unwrap(),
|
||||||
|
&self.locales,
|
||||||
|
&window_words,
|
||||||
|
) > 0.8
|
||||||
|
{
|
||||||
|
exact_appid_match
|
||||||
|
} else {
|
||||||
|
fde::matching::get_best_match(
|
||||||
|
&window_words,
|
||||||
|
&self.desktop_entries,
|
||||||
|
fde::matching::MatchAppIdOptions::default(),
|
||||||
|
)
|
||||||
|
.and_then(|de| {
|
||||||
|
let score = fde::matching::get_entry_score(
|
||||||
|
&query,
|
||||||
|
de,
|
||||||
|
&self.locales,
|
||||||
|
&window_words,
|
||||||
|
);
|
||||||
|
|
||||||
if score > 0.8 {
|
if score > 0.8 {
|
||||||
Some(de)
|
Some(de)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(de) = entry {
|
if let Some(de) = entry {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue