From dc7388f2cdf3afd14f982760e113ed8c4ea36a88 Mon Sep 17 00:00:00 2001 From: mertcandav Date: Sun, 24 Mar 2024 21:12:41 +0300 Subject: [PATCH] julefmt: improve slice literal support --- src/format.jule | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/format.jule b/src/format.jule index 5fb7afa..30d81b9 100644 --- a/src/format.jule +++ b/src/format.jule @@ -1195,8 +1195,7 @@ impl ExprFormatter { self.write("}") } - fn brace_lit(self, mut lit: &ast::BraceLit) { - self.write("{") + fn responsive_exprs[T](self, mut &lit: T) { self.fmt.add_indent() let mut row = lit.token.row let mut lined = false @@ -1221,6 +1220,11 @@ impl ExprFormatter { self.write("\n") self.write(self.fmt.indent) } + } + + fn brace_lit(self, mut lit: &ast::BraceLit) { + self.write("{") + self.responsive_exprs[&ast::BraceLit](lit) self.write("}") } @@ -1232,7 +1236,7 @@ impl ExprFormatter { fn slice(self, mut s: &ast::SliceExpr) { self.write("[") - self.args_data(s.elems) + self.responsive_exprs[&ast::SliceExpr](s) self.write("]") }