From e6ce65b214966b54c9f19bcc5b8bf12c80c57d06 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Fri, 24 Nov 2017 12:05:02 +0900 Subject: [PATCH] Put rhs on the same line as lhs if putting rhs on next line exceeds max width --- src/expr.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/expr.rs b/src/expr.rs index ad8cb25b53f..4c651a2bd37 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2632,6 +2632,12 @@ pub fn choose_rhs( let new_indent_str = &new_shape.indent.to_string(context.config); match (orig_rhs, new_rhs) { + (Some(ref orig_rhs), Some(ref new_rhs)) + if wrap_str(new_rhs.clone(), context.config.max_width(), new_shape) + .is_none() => + { + Some(format!(" {}", orig_rhs)) + } (Some(ref orig_rhs), Some(ref new_rhs)) if prefer_next_line(orig_rhs, new_rhs) => { Some(format!("\n{}{}", new_indent_str, new_rhs)) } -- 2.44.0