-
Notifications
You must be signed in to change notification settings - Fork 943
Prioritize single_line_fn and empty_item_single_line over brace_style #3308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When either one of these two options are set to `true`, each should take precedence over the brace_style option. This commit does not introduce any formatting change to the default configuration, so no version gate is required.
@@ -390,42 +392,37 @@ impl<'a> FmtVisitor<'a> { | |||
|
|||
if self.config.empty_item_single_line() | |||
&& is_empty_block(block, None, source_map) | |||
&& self.block_indent.width() + fn_str.len() + 2 <= self.config.max_width() | |||
&& self.block_indent.width() + fn_str.len() + 3 <= self.config.max_width() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it a 3 now instead of a 2 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for a space between fn_str
and the opening brace.
|
||
None | ||
let width = self.block_indent.width() + fn_str.len() + res.len() + 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it 5 and before it was 4 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for a space between fn_str
and the opening brace.
None | ||
let width = self.block_indent.width() + fn_str.len() + res.len() + 5; | ||
if !res.contains('\n') && width <= self.config.max_width() { | ||
Some(format!("{} {{ {} }}", fn_str, res)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an extra space right after fn_str
, is it on purpose ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Previously we added spaces and the opening brace before calling |
thanks @topecongiro for the clarifications! |
When either one of these two options are set to
true
, each should takeprecedence over the brace_style option.
This commit does not introduce any formatting change to the default
configuration, so no version gate is required.
Closes #2835.