File tree Expand file tree Collapse file tree 1 file changed +36
-15
lines changed
plugins/src/cosmic_toplevel Expand file tree Collapse file tree 1 file changed +36
-15
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use pop_launcher::{
21
21
} ;
22
22
use std:: borrow:: Cow ;
23
23
use std:: iter;
24
+ use std:: time:: Instant ;
24
25
use tokio:: io:: { AsyncWrite , AsyncWriteExt } ;
25
26
26
27
use self :: toplevel_handler:: { toplevel_handler, ToplevelAction } ;
@@ -194,21 +195,41 @@ impl<W: AsyncWrite + Unpin> App<W> {
194
195
. chain ( iter:: once ( info. title . as_str ( ) ) )
195
196
. collect :: < Vec < _ > > ( ) ;
196
197
197
- fde:: matching:: get_best_match (
198
- & window_words,
199
- & self . desktop_entries ,
200
- fde:: matching:: MatchAppIdOptions :: default ( ) ,
201
- )
202
- . and_then ( |de| {
203
- let score =
204
- fde:: matching:: get_entry_score ( & query, de, & self . locales , & window_words) ;
205
-
206
- if score > 0.8 {
207
- Some ( de)
208
- } else {
209
- None
210
- }
211
- } )
198
+ // if there's an exact appid match, use that instead
199
+ let exact_appid_match = self
200
+ . desktop_entries
201
+ . iter ( )
202
+ . find ( |de| de. appid == info. app_id ) ;
203
+ if exact_appid_match. is_some ( )
204
+ && fde:: matching:: get_entry_score (
205
+ & query,
206
+ exact_appid_match. unwrap ( ) ,
207
+ & self . locales ,
208
+ & window_words,
209
+ ) > 0.8
210
+ {
211
+ exact_appid_match
212
+ } else {
213
+ fde:: matching:: get_best_match (
214
+ & window_words,
215
+ & self . desktop_entries ,
216
+ fde:: matching:: MatchAppIdOptions :: default ( ) ,
217
+ )
218
+ . and_then ( |de| {
219
+ let score = fde:: matching:: get_entry_score (
220
+ & query,
221
+ de,
222
+ & self . locales ,
223
+ & window_words,
224
+ ) ;
225
+
226
+ if score > 0.8 {
227
+ Some ( de)
228
+ } else {
229
+ None
230
+ }
231
+ } )
232
+ }
212
233
} ;
213
234
214
235
if let Some ( de) = entry {
You can’t perform that action at this time.
0 commit comments