Skip to content

Commit e44d6cd

Browse files
wash2mmstick
authored andcommitted
fix(cosmic_toplevel): require higher score & match individual title words
1 parent 1725320 commit e44d6cd

File tree

1 file changed

+13
-10
lines changed
  • plugins/src/cosmic_toplevel

1 file changed

+13
-10
lines changed

plugins/src/cosmic_toplevel/mod.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use pop_launcher::{
1818
Request,
1919
};
2020
use std::borrow::Cow;
21+
use std::iter;
2122
use tokio::io::{AsyncWrite, AsyncWriteExt};
2223

2324
use self::toplevel_handler::{toplevel_handler, ToplevelAction, ToplevelEvent};
@@ -169,20 +170,23 @@ impl<W: AsyncWrite + Unpin> App<W> {
169170
fde::matching::MatchAppIdOptions::default(),
170171
)
171172
} else {
173+
let lowercase_title = info.title.to_lowercase();
174+
let window_words = lowercase_title
175+
.split_whitespace()
176+
.chain(iter::once(info.app_id.as_str()))
177+
.chain(iter::once(info.title.as_str()))
178+
.collect::<Vec<_>>();
179+
172180
fde::matching::get_best_match(
173-
&[&info.app_id, &info.title],
181+
&window_words,
174182
&self.desktop_entries,
175183
fde::matching::MatchAppIdOptions::default(),
176184
)
177185
.and_then(|de| {
178-
let score = fde::matching::get_entry_score(
179-
&query,
180-
de,
181-
&self.locales,
182-
&[&info.app_id, &info.title],
183-
);
184-
185-
if score > 0.6 {
186+
let score =
187+
fde::matching::get_entry_score(&query, de, &self.locales, &window_words);
188+
189+
if score > 0.8 {
186190
Some(de)
187191
} else {
188192
None
@@ -201,7 +205,6 @@ impl<W: AsyncWrite + Unpin> App<W> {
201205
// XXX protocol id may be re-used later
202206
id: handle.id().protocol_id(),
203207
window: Some((0, handle.id().clone().protocol_id())),
204-
// XXX: why this is inversed for this plugin ????
205208
description: info.title.clone(),
206209
name: get_description(de, &self.locales),
207210
icon: Some(IconSource::Name(icon_name)),

0 commit comments

Comments
 (0)