@@ -3048,7 +3048,7 @@ fn handle_jsx_surrounding_parens<'a>(inner_items: PrintItems, context: &mut Cont
3048
3048
}
3049
3049
}
3050
3050
3051
- if context. parent ( ) . is :: < JSXExprContainer > ( ) && context. config . jsx_multi_line_parens != JsxMultiLineParensStyle :: Always {
3051
+ if context. parent ( ) . is :: < JSXExprContainer > ( ) && context. config . jsx_multi_line_parens != JsxMultiLineParens :: Always {
3052
3052
return surround_with_newlines_indented_if_multi_line ( inner_items, context. config . indent_width ) ;
3053
3053
}
3054
3054
@@ -3093,7 +3093,7 @@ fn handle_jsx_surrounding_parens<'a>(inner_items: PrintItems, context: &mut Cont
3093
3093
}
3094
3094
3095
3095
fn is_jsx_paren_expr_handled_node ( node : & Node , context : & Context ) -> bool {
3096
- if context. config . jsx_multi_line_parens == JsxMultiLineParensStyle :: Never {
3096
+ if context. config . jsx_multi_line_parens == JsxMultiLineParens :: Never {
3097
3097
return false ;
3098
3098
}
3099
3099
@@ -3118,7 +3118,7 @@ fn is_jsx_paren_expr_handled_node(node: &Node, context: &Context) -> bool {
3118
3118
parent = parent. parent ( ) . unwrap ( ) ;
3119
3119
}
3120
3120
3121
- if context. config . jsx_multi_line_parens == JsxMultiLineParensStyle :: Always {
3121
+ if context. config . jsx_multi_line_parens == JsxMultiLineParens :: Always {
3122
3122
return true ;
3123
3123
}
3124
3124
@@ -7947,18 +7947,11 @@ fn jsx_space_separator(previous_node: &Node, current_node: &Node, context: &Cont
7947
7947
}
7948
7948
}
7949
7949
7950
- fn get_quote_char ( context : & Context ) -> String {
7951
- return match context. config . quote_style {
7952
- QuoteStyle :: PreferDouble | QuoteStyle :: AlwaysDouble => "\" " . to_string ( ) ,
7953
- QuoteStyle :: PreferSingle | QuoteStyle :: AlwaysSingle => "'" . to_string ( )
7954
- } ;
7955
- }
7956
-
7957
7950
fn jsx_force_space_with_newline_if_either_node_multi_line ( previous_node : & Node , current_node : & Node , context : & Context ) -> PrintItems {
7958
7951
let previous_node_info_range = get_node_info_range ( previous_node, context) ;
7959
7952
let current_node_info_range = get_node_info_range ( current_node, context) ;
7960
7953
let spaces_between_count = node_helpers:: count_spaces_between_jsx_children ( previous_node, current_node, & context. module ) ;
7961
- let jsx_space_expr_text = format ! ( "{{{}{}{}}}" , get_quote_char ( context ) , " " . repeat ( spaces_between_count) , get_quote_char ( context) ) ;
7954
+ let jsx_space_expr_text = get_jsx_space_text ( spaces_between_count, context) ;
7962
7955
if_true_or (
7963
7956
"jsxIsLastChildMultiLine" ,
7964
7957
move |condition_context| {
@@ -8005,7 +7998,7 @@ fn jsx_space_separator(previous_node: &Node, current_node: &Node, context: &Cont
8005
7998
8006
7999
if spaces_between_count > 1 {
8007
8000
items. push_signal ( Signal :: PossibleNewLine ) ;
8008
- items. push_string ( format ! ( "{{{}{}{}}}" , get_quote_char ( context ) , " " . repeat ( spaces_between_count) , get_quote_char ( context) ) ) ;
8001
+ items. push_string ( get_jsx_space_text ( spaces_between_count, context) ) ;
8009
8002
items. push_signal ( Signal :: PossibleNewLine ) ;
8010
8003
return items;
8011
8004
}
@@ -8045,7 +8038,7 @@ fn jsx_space_separator(previous_node: &Node, current_node: &Node, context: &Cont
8045
8038
true_path : {
8046
8039
let mut items = PrintItems :: new ( ) ;
8047
8040
items. push_signal ( Signal :: PossibleNewLine ) ;
8048
- items. push_string ( format ! ( "{{{} {}}}" , get_quote_char ( context) , get_quote_char ( context ) ) ) ;
8041
+ items. push_string ( get_jsx_space_text ( 1 , context) ) ;
8049
8042
items. push_signal ( Signal :: NewLine ) ;
8050
8043
Some ( items)
8051
8044
} ,
@@ -8058,6 +8051,17 @@ fn jsx_space_separator(previous_node: &Node, current_node: &Node, context: &Cont
8058
8051
}
8059
8052
}
8060
8053
8054
+ fn get_jsx_space_text ( spaces_between_count : usize , context : & Context ) -> String {
8055
+ format ! ( "{{{}{}{}}}" , get_quote_char( context) , " " . repeat( spaces_between_count) , get_quote_char( context) )
8056
+ }
8057
+
8058
+ fn get_quote_char ( context : & Context ) -> String {
8059
+ return match context. config . quote_style {
8060
+ QuoteStyle :: PreferDouble | QuoteStyle :: AlwaysDouble => "\" " . to_string ( ) ,
8061
+ QuoteStyle :: PreferSingle | QuoteStyle :: AlwaysSingle => "'" . to_string ( ) ,
8062
+ } ;
8063
+ }
8064
+
8061
8065
#[ inline]
8062
8066
fn parse_assignment < ' a > ( expr : Node < ' a > , op : & str , context : & mut Context < ' a > ) -> PrintItems {
8063
8067
parse_assignment_op_to ( expr, op, op, context)
0 commit comments