File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,30 @@ fn main() {
6
6
"Vanilla Cupcake" ,
7
7
"Chocolate Muffin" ,
8
8
"A Pile of sweet, sweet mustard" ,
9
+ "Carrots" ,
10
+ "Peas" ,
11
+ "Pistacio" ,
12
+ "Mustard" ,
13
+ "Cream" ,
14
+ "Banana" ,
15
+ "Chocolate" ,
16
+ "Flakes" ,
17
+ "Corn" ,
18
+ "Cake" ,
19
+ "Tarte" ,
20
+ "Cheddar" ,
21
+ "Vanilla" ,
22
+ "Hazelnut" ,
23
+ "Flour" ,
24
+ "Sugar" ,
25
+ "Salt" ,
26
+ "Potato" ,
27
+ "French Fries" ,
28
+ "Pizza" ,
29
+ "Mousse au chocolat" ,
30
+ "Brown sugar" ,
31
+ "Blueberry" ,
32
+ "Burger" ,
9
33
] ;
10
34
11
35
let selection = FuzzySelect :: with_theme ( & ColorfulTheme :: default ( ) )
Original file line number Diff line number Diff line change @@ -152,6 +152,12 @@ impl FuzzySelect<'_> {
152
152
// Fuzzy matcher
153
153
let matcher = fuzzy_matcher:: skim:: SkimMatcherV2 :: default ( ) ;
154
154
155
+ let term_size_rows = term. size ( ) . 0 as usize ;
156
+ // Subtract -2 because we need space to render the prompt.
157
+ let visible_term_rows = term_size_rows
158
+ . max ( 3 ) // Safeguard in case term_size_rows is 2 or less.
159
+ - 2 ;
160
+
155
161
term. hide_cursor ( ) ?;
156
162
157
163
loop {
@@ -164,6 +170,7 @@ impl FuzzySelect<'_> {
164
170
. iter ( )
165
171
. map ( |item| ( item, matcher. fuzzy_match ( item, & search_term) ) )
166
172
. filter_map ( |( item, score) | score. map ( |s| ( item, s) ) )
173
+ . take ( visible_term_rows)
167
174
. collect :: < Vec < _ > > ( ) ;
168
175
169
176
// Renders all matching items, from best match to worst.
You can’t perform that action at this time.
0 commit comments