Skip to content

Commit a6ab720

Browse files
authored
Keep [private] attribute when formatting assignments (#2592)
1 parent ab3da9b commit a6ab720

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/assignment.rs

+5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ pub(crate) type Assignment<'src> = Binding<'src, Expression<'src>>;
55

66
impl Display for Assignment<'_> {
77
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
8+
if self.private {
9+
writeln!(f, "[private]")?;
10+
}
11+
812
if self.export {
913
write!(f, "export ")?;
1014
}
15+
1116
write!(f, "{} := {}", self.name, self.value)
1217
}
1318
}

tests/format.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1155,3 +1155,22 @@ fn if_else() {
11551155
)
11561156
.run();
11571157
}
1158+
1159+
#[test]
1160+
fn private_variable() {
1161+
Test::new()
1162+
.justfile(
1163+
"
1164+
[private]
1165+
foo := 'bar'
1166+
",
1167+
)
1168+
.arg("--dump")
1169+
.stdout(
1170+
"
1171+
[private]
1172+
foo := 'bar'
1173+
",
1174+
)
1175+
.run();
1176+
}

0 commit comments

Comments
 (0)