File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -951,15 +951,18 @@ impl Formatter<'_> {
951
951
}
952
952
}
953
953
} ) ;
954
- if formatted. starts_with ( |c : char | c. is_ascii_digit ( ) )
955
- && ( self
956
- . output
957
- . ends_with ( |c : char | c. is_ascii_digit ( ) || c == '¯' )
958
- || self . output . ends_with ( '.' )
959
- && ( self . output . chars ( ) . nth_back ( 1 ) )
960
- . is_some_and ( |c| c. is_ascii_digit ( ) ) )
954
+ let curr = & mut self . output ;
955
+ let new_starts_ascii = formatted. starts_with ( |c : char | c. is_ascii_digit ( ) ) ;
956
+ let new_starts_glyph = formatted. starts_with ( [ '∞' , 'η' , 'π' , 'τ' ] ) ;
957
+ let curr_ends_neg = curr. ends_with ( '¯' ) ;
958
+ let curr_ends_ascii_or_neg =
959
+ curr_ends_neg || curr. ends_with ( |c : char | c. is_ascii_digit ( ) ) ;
960
+ let curr_ends_num_dup = curr. ends_with ( '.' )
961
+ && ( curr. chars ( ) . nth_back ( 1 ) ) . is_some_and ( |c| c. is_ascii_digit ( ) ) ;
962
+ if new_starts_ascii && ( curr_ends_ascii_or_neg || curr_ends_num_dup)
963
+ || new_starts_glyph && curr_ends_neg
961
964
{
962
- self . output . push ( ' ' ) ;
965
+ curr . push ( ' ' ) ;
963
966
}
964
967
self . push ( & word. span , & formatted) ;
965
968
}
You can’t perform that action at this time.
0 commit comments