Skip to content

Commit 70f0694

Browse files
committed
Support having static variables one lined if it fits within width.
1 parent 4ad8229 commit 70f0694

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/odin/printer/visit.odin

+9
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,15 @@ visit_attributes :: proc(p: ^Printer, attributes: ^[dynamic]^ast.Attribute, pos:
812812

813813
document = cons(document, move_line(p, attributes[0].pos))
814814

815+
//Ensure static is not forced newline, but until if the width is full
816+
if len(attributes) == 1 && len(attributes[0].elems) == 1 {
817+
if ident, ok := attributes[0].elems[0].derived.(^ast.Ident); ok && ident.name == "static" {
818+
document = cons(document, text("@"), text("("), visit_expr(p, attributes[0].elems[0]), text(")"))
819+
set_source_position(p, pos)
820+
return document
821+
}
822+
}
823+
815824
for attribute, i in attributes {
816825
document = cons(document, text("@"), text("("), visit_exprs(p, attribute.elems, {.Add_Comma}), text(")"))
817826

0 commit comments

Comments
 (0)