@@ -337,9 +337,6 @@ fn handle_plugin_cta_mouse(app: &mut App, mouse: MouseEvent) -> Option<Vec<ViewE
337337 Some ( Vec :: new ( ) )
338338}
339339
340- /// Handle mouse events within the composer area.
341- /// Returns true if the event was consumed.
342-
343340/// Slash-autocomplete rows painted inside the composer. Click selects
344341/// (second click on the same row applies, matching the command palette);
345342/// wheel moves the highlight. Returns true when the event was consumed so
@@ -349,12 +346,13 @@ fn handle_slash_autocomplete_mouse(app: &mut App, mouse: MouseEvent) -> bool {
349346 if hitboxes. is_empty ( ) {
350347 return false ;
351348 }
352- let over_row = hitboxes. iter ( ) . find_map ( | ( idx , rect ) | {
353- mouse_hits_rect ( mouse , Some ( * rect ) ) . then_some ( * idx )
354- } ) ;
349+ let over_row = hitboxes
350+ . iter ( )
351+ . find_map ( | ( idx , rect ) | mouse_hits_rect ( mouse , Some ( * rect ) ) . then_some ( * idx ) ) ;
355352 let over_menu = over_row. is_some ( )
356353 || hitboxes. iter ( ) . any ( |( _, rect) | {
357- mouse. row >= rect. y && mouse. row < rect. y . saturating_add ( rect. height )
354+ mouse. row >= rect. y
355+ && mouse. row < rect. y . saturating_add ( rect. height )
358356 && mouse. column >= rect. x
359357 && mouse. column < rect. x . saturating_add ( rect. width )
360358 } ) ;
@@ -405,6 +403,8 @@ fn handle_slash_autocomplete_mouse(app: &mut App, mouse: MouseEvent) -> bool {
405403 }
406404}
407405
406+ /// Handle mouse events within the composer area.
407+ /// Returns true if the event was consumed.
408408pub ( crate ) fn handle_composer_mouse ( app : & mut App , mouse : MouseEvent ) -> bool {
409409 // Use outer area for hit-testing (includes border).
410410 let Some ( area) = app. viewport . last_composer_area else {
@@ -1973,8 +1973,6 @@ mod tests {
19731973 crate :: tui:: hover_layer:: clear_pointer ( ) ;
19741974 }
19751975
1976-
1977-
19781976 #[ test]
19791977 fn slash_autocomplete_click_selects_and_second_click_applies ( ) {
19801978 let mut app = create_test_app ( ) ;
@@ -1986,18 +1984,22 @@ mod tests {
19861984 app. slash_menu_selected = 0 ;
19871985 // Simulate two painted rows from ComposerWidget.
19881986 app. viewport . last_composer_area = Some ( Rect :: new ( 0 , 18 , 80 , 6 ) ) ;
1989- * app. viewport . last_slash_menu_hitboxes . borrow_mut ( ) = vec ! [
1990- ( 0 , Rect :: new( 1 , 20 , 78 , 1 ) ) ,
1991- ( 1 , Rect :: new( 1 , 21 , 78 , 1 ) ) ,
1992- ] ;
1987+ * app. viewport . last_slash_menu_hitboxes . borrow_mut ( ) =
1988+ vec ! [ ( 0 , Rect :: new( 1 , 20 , 78 , 1 ) ) , ( 1 , Rect :: new( 1 , 21 , 78 , 1 ) ) ] ;
19931989
19941990 assert ! (
19951991 handle_composer_mouse( & mut app, left_click( 5 , 21 ) ) ,
19961992 "slash row click must be consumed by the composer"
19971993 ) ;
1998- assert_eq ! ( app. slash_menu_selected, 1 , "click on another row highlights it" ) ;
1994+ assert_eq ! (
1995+ app. slash_menu_selected, 1 ,
1996+ "click on another row highlights it"
1997+ ) ;
19991998 let before = app. input . clone ( ) ;
2000- assert_eq ! ( before, "/he" , "select-only click must not rewrite the composer" ) ;
1999+ assert_eq ! (
2000+ before, "/he" ,
2001+ "select-only click must not rewrite the composer"
2002+ ) ;
20012003
20022004 assert ! ( handle_composer_mouse( & mut app, left_click( 5 , 21 ) ) ) ;
20032005 assert_ne ! ( app. input, before, "click on the highlighted row applies it" ) ;
@@ -2018,10 +2020,8 @@ mod tests {
20182020 app. slash_menu_hidden = false ;
20192021 app. slash_menu_selected = 0 ;
20202022 app. viewport . last_composer_area = Some ( Rect :: new ( 0 , 18 , 80 , 6 ) ) ;
2021- * app. viewport . last_slash_menu_hitboxes . borrow_mut ( ) = vec ! [
2022- ( 0 , Rect :: new( 1 , 20 , 78 , 1 ) ) ,
2023- ( 1 , Rect :: new( 1 , 21 , 78 , 1 ) ) ,
2024- ] ;
2023+ * app. viewport . last_slash_menu_hitboxes . borrow_mut ( ) =
2024+ vec ! [ ( 0 , Rect :: new( 1 , 20 , 78 , 1 ) ) , ( 1 , Rect :: new( 1 , 21 , 78 , 1 ) ) ] ;
20252025 let entries = crate :: tui:: slash_menu:: visible_slash_menu_entries ( & app, 128 ) ;
20262026 assert ! ( entries. len( ) >= 2 , "prefix must offer multiple entries" ) ;
20272027
@@ -2048,7 +2048,6 @@ mod tests {
20482048 assert_eq ! ( app. slash_menu_selected, 0 ) ;
20492049 }
20502050
2051-
20522051 #[ test]
20532052 fn send_click_matches_the_keyboard_submit_and_focus_never_leaves_the_composer ( ) {
20542053 let mut app = create_test_app ( ) ;
0 commit comments