Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/fmt/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,13 @@ impl Iterator for CommentStateCharIndices<'_> {
}

#[inline]
fn count(self) -> usize {
self.iter.count()
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
fn count(self) -> usize {
self.iter.count()
}
}

Expand Down
8 changes: 6 additions & 2 deletions crates/fmt/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,12 @@ impl<'a, W: Write> Formatter<'a, W> {
.take_while(|(idx, ch)| ch.is_whitespace() && *idx <= self.buf.current_indent_len())
.count();
let to_skip = indent_whitespace_count - indent_whitespace_count % self.config.tab_width;
write!(self.buf(), " * ")?;
self.write_comment_line(comment, &line[to_skip..])?;
write!(self.buf(), " *")?;
let content = &line[to_skip..];
if !content.trim().is_empty() {
write!(self.buf(), " ")?;
self.write_comment_line(comment, &line[to_skip..])?;
}
self.write_whitespace_separator(true)?;
Ok(())
}
Expand Down
20 changes: 20 additions & 0 deletions crates/fmt/testdata/BlockCommentsFunction/fmt.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
contract A {
Counter public counter;
/**
* TODO: this fuzz use too much time to execute
* function testGetFuzz(bytes[2][] memory kvs) public {
* for (uint256 i = 0; i < kvs.length; i++) {
* bytes32 root = trie.update(kvs[i][0], kvs[i][1]);
* console.logBytes32(root);
* }
*
* for (uint256 i = 0; i < kvs.length; i++) {
* (bool exist, bytes memory value) = trie.get(kvs[i][0]);
* console.logBool(exist);
* console.logBytes(value);
* require(exist);
* require(BytesSlice.equal(value, trie.getRaw(kvs[i][0])));
* }
* }
*/
}
20 changes: 20 additions & 0 deletions crates/fmt/testdata/BlockCommentsFunction/original.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
contract A {
Counter public counter;
/**
* TODO: this fuzz use too much time to execute
function testGetFuzz(bytes[2][] memory kvs) public {
for (uint256 i = 0; i < kvs.length; i++) {
bytes32 root = trie.update(kvs[i][0], kvs[i][1]);
console.logBytes32(root);
}

for (uint256 i = 0; i < kvs.length; i++) {
(bool exist, bytes memory value) = trie.get(kvs[i][0]);
console.logBool(exist);
console.logBytes(value);
require(exist);
require(BytesSlice.equal(value, trie.getRaw(kvs[i][0])));
}
}
*/
}
1 change: 1 addition & 0 deletions crates/fmt/tests/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ test_directories! {
EmitStatement,
Repros,
BlockComments,
BlockCommentsFunction,
EnumVariants,
}

Expand Down