@@ -58,6 +58,42 @@ pub(crate) fn expand_badge_reserved_width(badge_text: &str) -> usize {
5858 UnicodeWidthStr :: width ( format ! ( " [{}⇧E]{badge_text}" , copy_badge_alt_label( ) ) . as_str ( ) )
5959}
6060
61+ fn expand_badge_spans (
62+ alt_label : & str ,
63+ alt_active : bool ,
64+ shift_active : bool ,
65+ key_active : bool ,
66+ expanded : bool ,
67+ ) -> [ Span < ' static > ; 7 ] {
68+ let dim = Style :: default ( ) . fg ( dim_color ( ) ) ;
69+ let modifier = |active| {
70+ if active {
71+ Style :: default ( ) . fg ( queued_color ( ) ) . bold ( )
72+ } else {
73+ dim
74+ }
75+ } ;
76+ let key_style = if key_active {
77+ Style :: default ( ) . fg ( accent_color ( ) ) . bold ( )
78+ } else {
79+ dim
80+ } ;
81+ let ( label, label_style) = if expanded {
82+ ( " ✓ Expanded" , Style :: default ( ) . fg ( ai_color ( ) ) . bold ( ) )
83+ } else {
84+ ( " expand" , dim)
85+ } ;
86+ [
87+ Span :: styled ( " " , dim) ,
88+ Span :: styled ( "[" , dim) ,
89+ Span :: styled ( alt_label. to_owned ( ) , modifier ( alt_active) ) ,
90+ Span :: styled ( "⇧" , modifier ( shift_active) ) ,
91+ Span :: styled ( "E" , key_style) ,
92+ Span :: styled ( "]" , dim) ,
93+ Span :: styled ( label, label_style) ,
94+ ]
95+ }
96+
6197fn expand_badge_target_line ( active : & ActiveFileDiffContext , inline : bool ) -> usize {
6298 if inline {
6399 active. end_line . saturating_sub ( 1 ) . max ( active. start_line )
@@ -809,36 +845,14 @@ pub(super) fn draw_messages(
809845 * width = ( * width) . saturating_sub ( reserved as u16 ) ;
810846 }
811847
812- let alt_style = if copy_badge_ui. alt_is_active ( copy_badge_now) {
813- Style :: default ( ) . fg ( queued_color ( ) ) . bold ( )
814- } else {
815- Style :: default ( ) . fg ( dim_color ( ) )
816- } ;
817- let shift_style = if copy_badge_ui. shift_is_active ( copy_badge_now) {
818- Style :: default ( ) . fg ( queued_color ( ) ) . bold ( )
819- } else {
820- Style :: default ( ) . fg ( dim_color ( ) )
821- } ;
822- let key_style = if copy_badge_ui. key_is_active ( 'e' , copy_badge_now) {
823- Style :: default ( ) . fg ( accent_color ( ) ) . bold ( )
824- } else {
825- Style :: default ( ) . fg ( dim_color ( ) )
826- } ;
827-
828848 let badge_start = line. width ( ) . saturating_add ( 1 ) ;
829- line. spans . push ( Span :: raw ( " " ) ) ;
830- line. spans . push ( Span :: raw ( "[" ) ) ;
831- line. spans
832- . push ( Span :: styled ( copy_badge_alt_label ( ) , alt_style) ) ;
833- line. spans . push ( Span :: styled ( "⇧" , shift_style) ) ;
834- line. spans . push ( Span :: styled ( "E" , key_style) ) ;
835- line. spans . push ( Span :: raw ( "]" ) ) ;
836- let badge_text_style = if expand_feedback_active {
837- Style :: default ( ) . fg ( ai_color ( ) ) . bold ( )
838- } else {
839- Style :: default ( ) . fg ( dim_color ( ) )
840- } ;
841- line. spans . push ( Span :: styled ( badge_text, badge_text_style) ) ;
849+ line. spans . extend ( expand_badge_spans (
850+ & copy_badge_alt_label ( ) ,
851+ copy_badge_ui. alt_is_active ( copy_badge_now) ,
852+ copy_badge_ui. shift_is_active ( copy_badge_now) ,
853+ copy_badge_ui. key_is_active ( 'e' , copy_badge_now) ,
854+ expand_feedback_active,
855+ ) ) ;
842856
843857 let final_width = line. width ( ) ;
844858 let aligned_x = match line. alignment . unwrap_or ( Alignment :: Left ) {
0 commit comments