From 620650219e5c456a770a9ea9952a8afffe875ea4 Mon Sep 17 00:00:00 2001 From: Pavel Sountsov Date: Fri, 18 Sep 2015 23:57:27 -0700 Subject: [PATCH] Use the block_indent inside visit_expr. This seems to pass all the tests and greatly improves the formatting output when using hard tabs. --- src/visitor.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/visitor.rs b/src/visitor.rs index 5426d9bae900..7c56bf675c71 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -39,12 +39,9 @@ impl<'a, 'v> visit::Visitor<'v> for FmtVisitor<'a> { self.codemap.lookup_char_pos(ex.span.hi)); self.format_missing(ex.span.lo); - let offset = self.buffer.cur_offset(); - // FIXME: We put the entire offset into the block_indent, which might not be correct in all - // situations. let rewrite = ex.rewrite(&self.get_context(), - self.config.max_width - offset, - Indent::new(offset, 0)); + self.config.max_width - self.block_indent.width(), + self.block_indent); if let Some(new_str) = rewrite { self.buffer.push_str(&new_str);