Compress an array with simple items

This commit is contained in:
topecongiro 2017-12-04 12:07:06 +09:00
parent 8cf99b1d90
commit 1684df6a0a

View File

@ -501,7 +501,7 @@ fn array_tactic<T: Rewrite + Spanned + ToExpr>(
match context.config.indent_style() {
IndentStyle::Block => {
match shape.width.checked_sub(2 * bracket_size) {
let tactic = match shape.width.checked_sub(2 * bracket_size) {
Some(width) => {
let tactic = ListTactic::LimitedHorizontalVertical(
context.config.width_heuristics().array_width,
@ -509,6 +509,13 @@ fn array_tactic<T: Rewrite + Spanned + ToExpr>(
definitive_tactic(items, tactic, Separator::Comma, width)
}
None => DefinitiveListTactic::Vertical,
};
if tactic == DefinitiveListTactic::Vertical && !has_long_item
&& is_every_args_simple(exprs)
{
DefinitiveListTactic::Mixed
} else {
tactic
}
}
IndentStyle::Visual => {