Skip to content

Commit 63b1c55

Browse files
committed
fix(fmt): return diff if source from stdin
1 parent 918eb6a commit 63b1c55

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/forge/src/cmd/fmt.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ impl FmtArgs {
127127
let path = source_unit.file.name.as_real();
128128
let original = source_unit.file.src.as_str();
129129
let formatted = forge_fmt::format_ast(gcx, source_unit, fmt_config.clone())?;
130+
let from_stdin = path.is_none();
130131

131-
if original == formatted {
132+
// If no diff then continue only if source loaded from stdin.
133+
// <https://github.com/foundry-rs/foundry/issues/11871>
134+
if original == formatted && (!from_stdin || self.check || self.raw) {
132135
return None;
133136
}
134137

135-
if self.check || path.is_none() {
138+
if self.check || from_stdin {
136139
let summary = if self.raw {
137140
formatted
138141
} else {

0 commit comments

Comments
 (0)