@@ -69,7 +69,9 @@ export class Launcher extends search.Search {
69
69
plugin . config . icon ,
70
70
icon ,
71
71
this . icon_size ( ) ,
72
- { plugin, id : selection . id }
72
+ { plugin, id : selection . id } ,
73
+ null ,
74
+ null
73
75
) )
74
76
}
75
77
}
@@ -97,14 +99,16 @@ export class Launcher extends search.Search {
97
99
const name = app . name ( )
98
100
const keywords = app . keywords ( )
99
101
const exec = app . exec ( )
100
- const app_items = keywords !== null ?
101
- name . split ( ) . concat ( keywords ) . concat ( exec ) : name . split ( ) . concat ( exec )
102
-
102
+
103
+ let app_items = name . split ( ' ' )
104
+ if ( keywords !== null ) app_items = app_items . concat ( keywords )
105
+ if ( exec !== null ) app_items = app_items . concat ( exec )
106
+
103
107
for ( const item of app_items ) {
104
108
const item_match = item . toLowerCase ( )
105
109
if ( item_match . startsWith ( pattern )
106
110
|| item_match . includes ( pattern )
107
- || levenshtein . compare ( item_match , pattern ) < 3 {
111
+ || levenshtein . compare ( item_match , pattern ) < 3 ) {
108
112
const generic = app . generic_name ( ) ;
109
113
const button = new launch . SearchOption (
110
114
name ,
@@ -136,14 +140,14 @@ export class Launcher extends search.Search {
136
140
// Sort by metadata (name, description, keywords)
137
141
if ( ! a_name . startsWith ( pattern ) ) {
138
142
a_weight = 1
139
- if ( ! a_name . includes ( pattern ) {
143
+ if ( ! a_name . includes ( pattern ) ) {
140
144
a_weight = levenshtein . compare ( a_name , pattern )
141
145
if ( a . description ) {
142
146
a_weight = Math . min ( a_weight , levenshtein . compare ( pattern , a . description . toLowerCase ( ) ) )
143
147
}
144
148
if ( a . keywords ) {
145
149
for ( const keyword of a . keywords ) {
146
- if keyword . toLowerCase ( ) . startsWith ( pattern ) || keyword . toLowerCase ( ) . includes ( pattern ) {
150
+ if ( keyword . toLowerCase ( ) . startsWith ( pattern ) || keyword . toLowerCase ( ) . includes ( pattern ) ) {
147
151
a_weight = 1
148
152
} else {
149
153
a_weight = Math . min ( a_weight , ( levenshtein . compare ( pattern , keyword . toLowerCase ( ) ) + 1 ) )
@@ -154,13 +158,13 @@ export class Launcher extends search.Search {
154
158
}
155
159
// Sort by command (exec)
156
160
if ( a_exec . includes ( pattern ) ) {
157
- if ( a_exec . startsWith ( pattern ) {
161
+ if ( a_exec . startsWith ( pattern ) ) {
158
162
a_weight = Math . min ( a_weight , 2 )
159
163
} else {
160
164
a_weight = Math . min ( a_weight , levenshtein . compare ( pattern , a_exec ) )
161
165
}
162
166
}
163
-
167
+
164
168
165
169
// Sort by metadata (name, description, keywords)
166
170
if ( ! b_name . startsWith ( pattern ) ) {
@@ -172,7 +176,7 @@ export class Launcher extends search.Search {
172
176
}
173
177
if ( b . keywords ) {
174
178
for ( const keyword of b . keywords ) {
175
- if keyword . toLowerCase ( ) . startsWith ( pattern ) || keyword . toLowerCase ( ) . includes ( pattern ) {
179
+ if ( keyword . toLowerCase ( ) . startsWith ( pattern ) || keyword . toLowerCase ( ) . includes ( pattern ) ) {
176
180
b_weight = 1
177
181
} else {
178
182
b_weight = Math . min ( b_weight , ( levenshtein . compare ( pattern , keyword . toLowerCase ( ) ) + 1 ) )
@@ -183,7 +187,7 @@ export class Launcher extends search.Search {
183
187
}
184
188
// Sort by command (exec)
185
189
if ( b_exec . includes ( pattern ) ) {
186
- if ( b_exec . startsWith ( pattern ) {
190
+ if ( b_exec . startsWith ( pattern ) ) {
187
191
b_weight = Math . min ( b_weight , 2 )
188
192
} else {
189
193
b_weight = Math . min ( b_weight , levenshtein . compare ( pattern , b_exec ) )
@@ -321,7 +325,7 @@ export class Launcher extends search.Search {
321
325
load_desktop_files ( ) {
322
326
lib . bench ( "load_desktop_files" , ( ) => {
323
327
this . desktop_apps . splice ( 0 ) ;
324
- for ( const _path of DATA_DIRS_USER . split ( ) . concat ( DATA_DIRS_SYSTEM ) ) {
328
+ for ( const _path of [ DATA_DIRS_USER ] . concat ( DATA_DIRS_SYSTEM ) ) {
325
329
const path = _path . replace ( / \/ $ / , '' ) + "/applications" ;
326
330
for ( const result of app_info . load_desktop_entries ( path ) ) {
327
331
if ( result . kind == OK ) {
@@ -397,6 +401,8 @@ function window_selection(ext: Ext, window: ShellWindow, icon_size: number): lau
397
401
widget : window . icon ( ext , icon_size )
398
402
} ,
399
403
icon_size ,
400
- { window }
404
+ { window } ,
405
+ null ,
406
+ null
401
407
)
402
408
}
0 commit comments