File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -2124,21 +2124,21 @@ pub(crate) fn rewrite_assign_rhs_expr<R: Rewrite>(
2124
2124
rhs_kind : & RhsAssignKind < ' _ > ,
2125
2125
rhs_tactics : RhsTactics ,
2126
2126
) -> RewriteResult {
2127
- let get_lhs_last_line_shape = || {
2128
- let last_line = lhs. rsplitn ( 2 , " \n " ) . next ( ) . unwrap_or_default ( ) ;
2127
+ let get_rhs_shape = || {
2128
+ let last_line = lhs. lines ( ) . last ( ) . unwrap_or_default ( ) ;
2129
2129
let tab_spaces = context. config . tab_spaces ( ) ;
2130
2130
let new_shape = shape
2131
2131
. block_indent ( tab_spaces)
2132
2132
. saturating_sub_width ( tab_spaces) ;
2133
- let extra_indent_string = new_shape. to_string ( & context. config ) . to_string ( ) ;
2134
- if last_line. starts_with ( & extra_indent_string) {
2133
+ let extra_indent_string = new_shape. to_string ( & context. config ) ;
2134
+ if last_line. starts_with ( extra_indent_string. as_ref ( ) ) {
2135
2135
new_shape
2136
2136
} else {
2137
2137
shape
2138
2138
}
2139
2139
} ;
2140
2140
let shape = if context. config . style_edition ( ) >= StyleEdition :: Edition2024 {
2141
- get_lhs_last_line_shape ( )
2141
+ get_rhs_shape ( )
2142
2142
} else {
2143
2143
shape
2144
2144
} ;
Original file line number Diff line number Diff line change @@ -278,6 +278,7 @@ impl Shape {
278
278
offset_indent. to_string_inner ( config, 0 )
279
279
}
280
280
281
+ /// similar to to_string_with_newline, except the result does not start with a new line
281
282
pub ( crate ) fn to_string ( & self , config : & Config ) -> Cow < ' static , str > {
282
283
let mut offset_indent = self . indent ;
283
284
offset_indent. alignment = self . offset ;
You can’t perform that action at this time.
0 commit comments