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> {
139139
140140 acc
141141 } ) ;
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+
143153 let width = len. min ( viewport. 0 as usize ) ;
144154
145155 self . widths = max_lens
146156 . into_iter ( )
147157 . map ( |len| Constraint :: Length ( len as u16 ) )
148158 . collect ( ) ;
149159
150- let height = self . matches . len ( ) . min ( 10 ) . min ( viewport. 1 as usize ) ;
151-
152160 self . size = ( width as u16 , height as u16 ) ;
153161
154162 // adjust scroll offsets if size changed
You can’t perform that action at this time.
0 commit comments