Skip to content

Commit

Permalink
fix(fmt): fix indent closing parenthesis enclosed in { } (#7557)
Browse files Browse the repository at this point in the history
* fix(fmt): fix indent closing parenthesis enclosed in { }

* Fix testdata bad formatting
  • Loading branch information
grandizzy authored Apr 4, 2024
1 parent f6208d8 commit 0875a83
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/fmt/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ impl<'a, W: Write> Formatter<'a, W> {
write_chunk!(fmt, "{}", stringified.trim_start())
})?;
if !last.content.trim_start().is_empty() {
self.write_whitespace_separator(true)?;
self.indented(1, |fmt| fmt.write_whitespace_separator(true))?;
}
let last_chunk =
self.chunk_at(last.loc_before(), last.loc_next(), last.spaced, &last.content);
Expand Down
12 changes: 12 additions & 0 deletions crates/fmt/testdata/Repros/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ function errorIdentifier() {
bytes memory error = bytes("");
if (error.length > 0) {}
}

// https://github.com/foundry-rs/foundry/issues/7549
function one() external {
this.other({
data: abi.encodeCall(
this.other,
(
"bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla"
)
)
});
}
12 changes: 12 additions & 0 deletions crates/fmt/testdata/Repros/original.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ function errorIdentifier() {
bytes memory error = bytes("");
if (error.length > 0) {}
}

// https://github.com/foundry-rs/foundry/issues/7549
function one() external {
this.other({
data: abi.encodeCall(
this.other,
(
"bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla"
)
)
});
}
2 changes: 1 addition & 1 deletion testdata/default/cheats/RecordAccountAccesses.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ contract RecordAccountAccessesTest is DSTest {
data: abi.encodeCall(
Create2or.create2,
(bytes32(0), abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(true)))
),
),
reverted: false,
storageAccesses: new Vm.StorageAccess[](0),
depth: 1
Expand Down

0 comments on commit 0875a83

Please sign in to comment.