From c211a44a0b74d4a3d64a156e7bc36159af1b9f47 Mon Sep 17 00:00:00 2001 From: Matthew McAllister Date: Mon, 30 Oct 2017 16:48:32 -0700 Subject: [PATCH] Fix handling when comment_width > max_width --- src/missed_spans.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/missed_spans.rs b/src/missed_spans.rs index 4cc48ee866d..3eae9069425 100644 --- a/src/missed_spans.rs +++ b/src/missed_spans.rs @@ -173,17 +173,17 @@ impl<'a> FmtVisitor<'a> { self.buffer.push_str(" "); } - let comment_width = if self.config.absolute_comment_width() { - self.config - .comment_width() - .checked_sub(self.block_indent.width()) - .unwrap_or(0) - } else { - ::std::cmp::min( - self.config.comment_width(), - self.config.max_width() - self.block_indent.width(), - ) - }; + let comment_width = ::std::cmp::min( + if self.config.absolute_comment_width() { + self.config + .comment_width() + .checked_sub(self.block_indent.width()) + .unwrap_or(0) + } else { + self.config.comment_width() + }, + self.config.max_width() - self.block_indent.width(), + ); let comment_indent = Indent::from_width(self.config, self.buffer.cur_offset()); self.buffer.push_str(&rewrite_comment(