@@ -11,7 +11,9 @@ pub struct Config {
11
11
max_entries : usize ,
12
12
terminal : Option < Terminal > ,
13
13
preprocess_exec_script : Option < PathBuf > ,
14
- entry_priority : Option < EntryPriority > ,
14
+
15
+ #[ serde( default ) ]
16
+ entry_priority : EntryPriority ,
15
17
}
16
18
17
19
#[ derive( Deserialize ) ]
@@ -20,8 +22,9 @@ pub struct Terminal {
20
22
args : String ,
21
23
}
22
24
23
- #[ derive( Deserialize ) ]
25
+ #[ derive( Deserialize , Default ) ]
24
26
pub enum EntryPriority {
27
+ #[ default]
25
28
ActionsFirst ,
26
29
ApplicationsFirst ,
27
30
NoPriority ,
@@ -34,7 +37,7 @@ impl Default for Config {
34
37
max_entries : 5 ,
35
38
preprocess_exec_script : None ,
36
39
terminal : None ,
37
- entry_priority : None ,
40
+ entry_priority : EntryPriority :: default ( ) ,
38
41
}
39
42
}
40
43
}
@@ -186,12 +189,6 @@ pub fn init(config_dir: RString) -> State {
186
189
#[ get_matches]
187
190
pub fn get_matches ( input : RString , state : & State ) -> RVec < Match > {
188
191
let matcher = fuzzy_matcher:: skim:: SkimMatcherV2 :: default ( ) . ignore_case ( ) ;
189
- let entry_priority = state
190
- . config
191
- . entry_priority
192
- . as_ref ( )
193
- . unwrap_or ( & EntryPriority :: ActionsFirst ) ;
194
-
195
192
let mut entries = state
196
193
. entries
197
194
. iter ( )
@@ -216,7 +213,7 @@ pub fn get_matches(input: RString, state: &State) -> RVec<Match> {
216
213
let mut score = ( name_score * 10 + desc_score + keyword_score) - entry. offset ;
217
214
218
215
// Apply priority
219
- score *= match ( entry_priority, entry. is_action ) {
216
+ score *= match ( & state . config . entry_priority , entry. is_action ) {
220
217
( EntryPriority :: ActionsFirst , true ) => 2 ,
221
218
( EntryPriority :: ApplicationsFirst , false ) => 2 ,
222
219
_ => 1 ,
0 commit comments