11use crossterm:: event:: { KeyCode , KeyEvent } ;
22use ratatui:: layout:: { Constraint , Layout , Rect } ;
33use ratatui:: text:: { Line , Span } ;
4- use ratatui:: widgets:: { Block , BorderType , Borders , Cell , Clear , List , ListItem , Paragraph , Row , Table } ;
4+ use ratatui:: widgets:: {
5+ Block , BorderType , Borders , Cell , Clear , List , ListItem , Paragraph , Row , Table ,
6+ } ;
57use ratatui:: Frame ;
68use tracing:: debug;
79
@@ -273,7 +275,10 @@ impl CommandPanel {
273275 match context {
274276 Some ( FilterContext :: Empty ) => {
275277 // Show filter templates
276- debug ! ( "update_completions: showing {} filter templates" , FILTER_TEMPLATES . len( ) ) ;
278+ debug ! (
279+ "update_completions: showing {} filter templates" ,
280+ FILTER_TEMPLATES . len( )
281+ ) ;
277282 self . completion_kind = CompletionKind :: Templates ;
278283 self . value_items = FILTER_TEMPLATES . iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ;
279284 self . completions = self
@@ -306,7 +311,9 @@ impl CommandPanel {
306311 self . attribute_names. len( ) ,
307312 ) ;
308313 if !self . completions . is_empty ( ) {
309- let top_matches: Vec < & str > = self . completions . iter ( )
314+ let top_matches: Vec < & str > = self
315+ . completions
316+ . iter ( )
310317 . take ( 5 )
311318 . map ( |m| self . attribute_names [ m. index ] . as_str ( ) )
312319 . collect ( ) ;
@@ -360,7 +367,9 @@ impl CommandPanel {
360367 }
361368 debug ! (
362369 "update_completions: Value attr={:?}, partial={:?}, {} value completions" ,
363- attr, partial, self . completions. len( )
370+ attr,
371+ partial,
372+ self . completions. len( )
364373 ) ;
365374 self . completions . truncate ( 50 ) ;
366375 self . completion_visible = !self . completions . is_empty ( ) ;
@@ -378,7 +387,11 @@ impl CommandPanel {
378387
379388 fn accept_completion ( & mut self ) {
380389 if !self . completion_visible || self . completions . is_empty ( ) {
381- debug ! ( "accept_completion: nothing to accept (visible={}, count={})" , self . completion_visible, self . completions. len( ) ) ;
390+ debug ! (
391+ "accept_completion: nothing to accept (visible={}, count={})" ,
392+ self . completion_visible,
393+ self . completions. len( )
394+ ) ;
382395 return ;
383396 }
384397
@@ -407,7 +420,10 @@ impl CommandPanel {
407420 self . input_buffer . push ( '=' ) ;
408421 self . cursor_pos = self . input_buffer . len ( ) ;
409422 self . input_buffer . push_str ( & suffix) ;
410- debug ! ( "accept_completion: buffer is now {:?}, cursor_pos={}" , self . input_buffer, self . cursor_pos) ;
423+ debug ! (
424+ "accept_completion: buffer is now {:?}, cursor_pos={}" ,
425+ self . input_buffer, self . cursor_pos
426+ ) ;
411427 }
412428 }
413429 CompletionKind :: Values => {
@@ -431,7 +447,10 @@ impl CommandPanel {
431447 self . input_buffer . push ( ')' ) ;
432448 self . cursor_pos = self . input_buffer . len ( ) ;
433449 self . input_buffer . push_str ( & suffix) ;
434- debug ! ( "accept_completion: buffer is now {:?}, cursor_pos={}" , self . input_buffer, self . cursor_pos) ;
450+ debug ! (
451+ "accept_completion: buffer is now {:?}, cursor_pos={}" ,
452+ self . input_buffer, self . cursor_pos
453+ ) ;
435454 }
436455 }
437456 CompletionKind :: Templates => {
@@ -482,7 +501,8 @@ impl CommandPanel {
482501 } else {
483502 debug ! (
484503 "tick: filter {:?} invalid: {:?}" ,
485- self . input_buffer, validation. err( )
504+ self . input_buffer,
505+ validation. err( )
486506 ) ;
487507 Action :: None
488508 }
@@ -738,8 +758,7 @@ impl CommandPanel {
738758 return ;
739759 }
740760
741- let target_row =
742- ( cursor_row as i32 + delta) . clamp ( 0 , ( lines. len ( ) - 1 ) as i32 ) as usize ;
761+ let target_row = ( cursor_row as i32 + delta) . clamp ( 0 , ( lines. len ( ) - 1 ) as i32 ) as usize ;
743762 if target_row == cursor_row {
744763 return ;
745764 }
@@ -805,7 +824,7 @@ impl CommandPanel {
805824 current_line = format ! ( "{}{}{}" , indent_str. repeat( indent) , ch, chars[ i + 1 ] ) ;
806825 let row = lines. len ( ) ;
807826 let col_base = indent * indent_str. len ( ) ;
808- cursor_map. push ( ( row, col_base) ) ; // '('
827+ cursor_map. push ( ( row, col_base) ) ; // '('
809828 cursor_map. push ( ( row, col_base + 1 ) ) ; // '&'/'|'/'!'
810829 lines. push ( current_line) ;
811830 current_line = String :: new ( ) ;
@@ -1061,8 +1080,7 @@ impl CommandPanel {
10611080 Constraint :: Percentage ( 25 ) ,
10621081 ] ;
10631082
1064- let table = Table :: new ( rows, widths)
1065- . header ( header. style ( self . theme . header ) ) ;
1083+ let table = Table :: new ( rows, widths) . header ( header. style ( self . theme . header ) ) ;
10661084
10671085 frame. render_widget ( table, inner) ;
10681086 }
@@ -1076,7 +1094,12 @@ impl CommandPanel {
10761094 let ( formatted_lines, cursor_row, cursor_col, _) = if self . input_active {
10771095 self . format_input_for_display ( )
10781096 } else {
1079- ( vec ! [ self . input_buffer. clone( ) ] , 0 , self . input_buffer . len ( ) , Vec :: new ( ) )
1097+ (
1098+ vec ! [ self . input_buffer. clone( ) ] ,
1099+ 0 ,
1100+ self . input_buffer . len ( ) ,
1101+ Vec :: new ( ) ,
1102+ )
10801103 } ;
10811104
10821105 if self . input_active {
@@ -1277,10 +1300,7 @@ impl Component for CommandPanel {
12771300 Span :: styled( at. to_string( ) , self . theme. command_prompt) ,
12781301 ] ;
12791302 if !after. is_empty ( ) {
1280- spans. push ( Span :: styled (
1281- after. to_string ( ) ,
1282- self . theme . normal ,
1283- ) ) ;
1303+ spans. push ( Span :: styled ( after. to_string ( ) , self . theme . normal ) ) ;
12841304 }
12851305 Line :: from ( spans)
12861306 } else {
0 commit comments