From 79dba579f7da10008ec19e7ad593fc255103ee86 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 15 Dec 2022 13:08:53 -0800 Subject: [PATCH] Format exported variadic parameters correctly (#1451) --- src/parameter.rs | 6 +++--- tests/fmt.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/parameter.rs b/src/parameter.rs index fb55d2c..e065534 100644 --- a/src/parameter.rs +++ b/src/parameter.rs @@ -15,12 +15,12 @@ pub(crate) struct Parameter<'src> { impl<'src> ColorDisplay for Parameter<'src> { fn fmt(&self, f: &mut Formatter, color: Color) -> Result<(), fmt::Error> { - if self.export { - write!(f, "$")?; - } if let Some(prefix) = self.kind.prefix() { write!(f, "{}", color.annotation().paint(prefix))?; } + if self.export { + write!(f, "$")?; + } write!(f, "{}", color.parameter().paint(self.name.lexeme()))?; if let Some(ref default) = self.default { write!(f, "={}", color.string().paint(&default.to_string()))?; diff --git a/tests/fmt.rs b/tests/fmt.rs index e4c4687..348cb27 100644 --- a/tests/fmt.rs +++ b/tests/fmt.rs @@ -1042,3 +1042,12 @@ test! { echo foo ", } + +#[test] +fn exported_parameter() { + Test::new() + .justfile("foo +$f:") + .args(&["--dump"]) + .stdout("foo +$f:\n") + .run(); +}