Skip to content

Commit

Permalink
fix(fmt): add missing EOF newline (foundry-rs#2177)
Browse files Browse the repository at this point in the history
* fix(fmt): add missing EOF newline

* test(fmt): add missing EOL newlines to fmt.sol files
  • Loading branch information
xJonathanLEI authored Jul 1, 2022
1 parent 0d44687 commit 4431bc2
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion fmt/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,9 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> {
self.comments.remove_comments_before(self.source.len());
write_chunk!(self, self.source.len(), "{}", comments.trim_end())?;

// EOF newline
writeln!(self.buf())?;

Ok(())
}

Expand Down Expand Up @@ -2799,7 +2802,7 @@ mod tests {
}
let expected_comments = Comments::new(expected_comments, expected_source);

let expected = PrettyString(expected_source.trim().to_string());
let expected = PrettyString(expected_source.to_string());

let mut source_formatted = String::new();
let mut f = Formatter::new(&mut source_formatted, source, source_comments, config.clone());
Expand Down
2 changes: 1 addition & 1 deletion fmt/testdata/ArrayExpressions/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ contract ArrayExpressions {
uint256[1] memory literal3 =
[ /* comment11 */ someVeryVeryLongVariableName /* comment13 */ ];
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/ForStatement/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ contract ForStatement {
"test";
}
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/FunctionCallArgsStatement/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ contract FunctionCallArgsStatement {
gas: gasleft()
};
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/NamedFunctionCallExpression/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ contract NamedFunctionCallExpression {
// comment8
});
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/RevertStatement/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ contract RevertStatement {
someVeryLongFunctionNameToGetDynamicErrorMessageString() /* comment17 */
);
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/TernaryExpression/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ contract TernaryExpression {
// comment7
: 0; // comment8
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/ThisExpression/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ contract ThisExpression {
this // comment 4
);
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/TryStatement/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ contract TryStatement {
unknown.handleError();
} catch {}
}
}
}
2 changes: 1 addition & 1 deletion fmt/testdata/UnitExpression/fmt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ contract UnitExpression {
// comment4
ether; // comment5
}
}
}

0 comments on commit 4431bc2

Please sign in to comment.