@@ -27,7 +27,7 @@ impl SearchState {
2727 pub fn new ( ids : Vec < String > , focused_index : usize ) -> Self {
2828 let total = ids. len ( ) ;
2929 let selected = focused_index. min ( total. saturating_sub ( 1 ) ) ;
30- let scroll_offset = if selected > 4 { selected - 4 } else { 0 } ;
30+ let scroll_offset = selected. saturating_sub ( 4 ) ;
3131 Self {
3232 query : String :: new ( ) ,
3333 ids,
@@ -48,9 +48,7 @@ impl SearchState {
4848 . selected
4949 . min ( self . filtered_indices . len ( ) . saturating_sub ( 1 ) ) ;
5050 let filtered_total = self . filtered_indices . len ( ) ;
51- self . scroll_offset = self
52- . scroll_offset
53- . min ( filtered_total. saturating_sub ( 5 ) ) ;
51+ self . scroll_offset = self . scroll_offset . min ( filtered_total. saturating_sub ( 5 ) ) ;
5452 if self . scroll_offset > self . selected {
5553 self . scroll_offset = self . selected ;
5654 }
@@ -543,14 +541,14 @@ fn render_search_overlay<T: SearchItem>(
543541
544542 let input_prefix = " ● " ;
545543 let prefix_w = UnicodeWidthStr :: width ( input_prefix) as u16 ;
546- let max_input_w = input_area
547- . width
548- . saturating_sub ( prefix_w)
549- . saturating_sub ( 1 ) ;
544+ let max_input_w = input_area. width . saturating_sub ( prefix_w) . saturating_sub ( 1 ) ;
550545 let display_query = truncate_query_left ( & search. query , max_input_w) ;
551546 let input_line = Line :: from ( vec ! [
552547 Span :: styled( input_prefix, theme. muted_style( ) ) ,
553- Span :: styled( format!( "{}_" , display_query) , Style :: default ( ) . fg( theme. foreground) ) ,
548+ Span :: styled(
549+ format!( "{}_" , display_query) ,
550+ Style :: default ( ) . fg( theme. foreground) ,
551+ ) ,
554552 ] ) ;
555553 frame. render_widget ( Paragraph :: new ( input_line) , input_area) ;
556554 frame. render_widget (
0 commit comments