Skip to content

Commit 24509fe

Browse files
committed
Update per comments
1 parent 89f1e2b commit 24509fe

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/expr.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2124,21 +2124,21 @@ pub(crate) fn rewrite_assign_rhs_expr<R: Rewrite>(
21242124
rhs_kind: &RhsAssignKind<'_>,
21252125
rhs_tactics: RhsTactics,
21262126
) -> 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();
21292129
let tab_spaces = context.config.tab_spaces();
21302130
let new_shape = shape
21312131
.block_indent(tab_spaces)
21322132
.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()) {
21352135
new_shape
21362136
} else {
21372137
shape
21382138
}
21392139
};
21402140
let shape = if context.config.style_edition() >= StyleEdition::Edition2024 {
2141-
get_lhs_last_line_shape()
2141+
get_rhs_shape()
21422142
} else {
21432143
shape
21442144
};

src/shape.rs

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ impl Shape {
278278
offset_indent.to_string_inner(config, 0)
279279
}
280280

281+
/// similar to to_string_with_newline, except the result does not start with a new line
281282
pub(crate) fn to_string(&self, config: &Config) -> Cow<'static, str> {
282283
let mut offset_indent = self.indent;
283284
offset_indent.alignment = self.offset;

0 commit comments

Comments
 (0)