Format exported variadic parameters correctly (#1451)

This commit is contained in:
Casey Rodarmor 2022-12-15 13:08:53 -08:00 committed by GitHub
parent 1119d226fe
commit 79dba579f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -15,12 +15,12 @@ pub(crate) struct Parameter<'src> {
impl<'src> ColorDisplay for Parameter<'src> { impl<'src> ColorDisplay for Parameter<'src> {
fn fmt(&self, f: &mut Formatter, color: Color) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut Formatter, color: Color) -> Result<(), fmt::Error> {
if self.export {
write!(f, "$")?;
}
if let Some(prefix) = self.kind.prefix() { if let Some(prefix) = self.kind.prefix() {
write!(f, "{}", color.annotation().paint(prefix))?; write!(f, "{}", color.annotation().paint(prefix))?;
} }
if self.export {
write!(f, "$")?;
}
write!(f, "{}", color.parameter().paint(self.name.lexeme()))?; write!(f, "{}", color.parameter().paint(self.name.lexeme()))?;
if let Some(ref default) = self.default { if let Some(ref default) = self.default {
write!(f, "={}", color.string().paint(&default.to_string()))?; write!(f, "={}", color.string().paint(&default.to_string()))?;

View File

@ -1042,3 +1042,12 @@ test! {
echo foo echo foo
", ",
} }
#[test]
fn exported_parameter() {
Test::new()
.justfile("foo +$f:")
.args(&["--dump"])
.stdout("foo +$f:\n")
.run();
}