File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -139,16 +139,24 @@ impl<T: Item> Menu<T> {
139
139
140
140
acc
141
141
} ) ;
142
- let len = max_lens. iter ( ) . sum :: < usize > ( ) + n + 1 ; // +1: reserve some space for scrollbar
142
+
143
+ let height = self . matches . len ( ) . min ( 10 ) . min ( viewport. 1 as usize ) ;
144
+ // do all the matches fit on a single screen?
145
+ let fits = self . matches . len ( ) <= height;
146
+
147
+ let mut len = max_lens. iter ( ) . sum :: < usize > ( ) + n;
148
+
149
+ if !fits {
150
+ len += 1 ; // +1: reserve some space for scrollbar
151
+ }
152
+
143
153
let width = len. min ( viewport. 0 as usize ) ;
144
154
145
155
self . widths = max_lens
146
156
. into_iter ( )
147
157
. map ( |len| Constraint :: Length ( len as u16 ) )
148
158
. collect ( ) ;
149
159
150
- let height = self . matches . len ( ) . min ( 10 ) . min ( viewport. 1 as usize ) ;
151
-
152
160
self . size = ( width as u16 , height as u16 ) ;
153
161
154
162
// adjust scroll offsets if size changed
You can’t perform that action at this time.
0 commit comments