From 101fbe9be4a78fa60943a5160c8c272584970b0b Mon Sep 17 00:00:00 2001 From: mertcandav Date: Tue, 2 Apr 2024 00:55:02 +0300 Subject: [PATCH] julefmt: minor improvements --- src/format.jule | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/format.jule b/src/format.jule index 7afd916..5f71b71 100644 --- a/src/format.jule +++ b/src/format.jule @@ -1466,9 +1466,24 @@ impl ExprFormatter { } fn unsafexpr(&self, mut u: &ast::UnsafeExpr) { - self.write("unsafe { ") + self.write("unsafe {") + let line = u.expr.token.row != u.expr.end.row + if line { + self.fmt.add_indent() + self.write("\n") + self.write(self.fmt.indent) + } else { + self.write(" ") + } self.format(u.expr) - self.write(" }") + if line { + self.fmt.done_indent() + self.write("\n") + self.write(self.fmt.indent) + } else { + self.write(" ") + } + self.write("}") } fn coexpr(&self, mut c: &ast::CoExpr) {