Skip to content

Commit

Permalink
Keep [private] attribute when formatting assignments (#2592)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 22, 2025
1 parent ab3da9b commit a6ab720
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ pub(crate) type Assignment<'src> = Binding<'src, Expression<'src>>;

impl Display for Assignment<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if self.private {
writeln!(f, "[private]")?;
}

if self.export {
write!(f, "export ")?;
}

write!(f, "{} := {}", self.name, self.value)
}
}
19 changes: 19 additions & 0 deletions tests/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,3 +1155,22 @@ fn if_else() {
)
.run();
}

#[test]
fn private_variable() {
Test::new()
.justfile(
"
[private]
foo := 'bar'
",
)
.arg("--dump")
.stdout(
"
[private]
foo := 'bar'
",
)
.run();
}

0 comments on commit a6ab720

Please sign in to comment.