Skip to content

Commit ee2b3b1

Browse files
committed
Put the opening brace of fn body on the next line if it exceeds max width
1 parent 26fa751 commit ee2b3b1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/items.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,12 @@ impl<'a> FmtVisitor<'a> {
250250
true,
251251
));
252252

253-
if force_newline_brace {
253+
if self.config.fn_brace_style() == BraceStyle::AlwaysNextLine || force_newline_brace {
254254
newline_brace = true;
255-
} else if self.config.fn_brace_style() != BraceStyle::AlwaysNextLine
256-
&& !result.contains('\n')
257-
{
255+
} else if last_line_width(&result) + 2 > self.shape().width {
256+
// 2 = ` {`
257+
newline_brace = true;
258+
} else if !result.contains('\n') {
258259
newline_brace = false;
259260
}
260261

0 commit comments

Comments
 (0)