Skip to content

Commit

Permalink
Fixes Shape::width bleed from file to file (FuelLabs#2727)
Browse files Browse the repository at this point in the history
* Fixes width bleed from file to file

* remove println, add indent level

* rmv testing from previous branch
  • Loading branch information
eureka-cpu authored Sep 6, 2022
1 parent a989e6c commit f6e3300
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions swayfmt/src/formatter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl Formatter {
if !formatted_code.ends_with('\n') {
writeln!(formatted_code)?;
}
self.shape.reset_width(); // bandaid shape reset TODO:(#2495)

Ok(formatted_code)
}
Expand Down
11 changes: 8 additions & 3 deletions swayfmt/src/items/item_fn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ impl Format for ItemFn {
formatter: &mut Formatter,
) -> Result<(), FormatterError> {
self.fn_signature.format(formatted_code, formatter)?;
Self::open_curly_brace(formatted_code, formatter)?;
self.body.get().format(formatted_code, formatter)?;
Self::close_curly_brace(formatted_code, formatter)?;
let body = self.body.get();
if !body.statements.is_empty() || body.final_expr_opt.is_some() {
Self::open_curly_brace(formatted_code, formatter)?;
self.body.get().format(formatted_code, formatter)?;
Self::close_curly_brace(formatted_code, formatter)?;
} else {
write!(formatted_code, " {{}}")?;
}

Ok(())
}
Expand Down

0 comments on commit f6e3300

Please sign in to comment.