From 97ec417e74485526992d1abf5fe709d434834898 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Thu, 5 Apr 2018 13:27:42 +0900 Subject: [PATCH] Add trailing comma when using mixed layout with block indent --- src/lists.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lists.rs b/src/lists.rs index 05b1a7ce296..d0e9863f2f4 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -172,11 +172,10 @@ pub fn definitive_tactic( let limit = match tactic { _ if pre_line_comments => return DefinitiveListTactic::Vertical, - ListTactic::Mixed => return DefinitiveListTactic::Mixed, ListTactic::Horizontal => return DefinitiveListTactic::Horizontal, ListTactic::Vertical => return DefinitiveListTactic::Vertical, ListTactic::LimitedHorizontalVertical(limit) => ::std::cmp::min(width, limit), - ListTactic::HorizontalVertical => width, + ListTactic::Mixed | ListTactic::HorizontalVertical => width, }; let (sep_count, total_width) = calculate_width(items.clone()); @@ -188,7 +187,10 @@ pub fn definitive_tactic( { DefinitiveListTactic::Horizontal } else { - DefinitiveListTactic::Vertical + match tactic { + ListTactic::Mixed => DefinitiveListTactic::Mixed, + _ => DefinitiveListTactic::Vertical, + } } } @@ -276,8 +278,7 @@ pub fn write_list(items: I, formatting: &ListFormatting) -> Option if last && formatting.ends_with_newline { match formatting.trailing_separator { - SeparatorTactic::Always => separate = true, - SeparatorTactic::Vertical if result.contains('\n') => separate = true, + SeparatorTactic::Always | SeparatorTactic::Vertical => separate = true, _ => (), } } -- 2.44.0