diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-05-31 11:41:46 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-05-31 17:34:03 -0400 |
| commit | a3c1fd4e5320aff6566b49afbec6ddee32964ce4 (patch) | |
| tree | 54a4bbdf312fee5a30d27957f05a59c2a477e206 | |
| parent | dba39a1e8420eacb60719e02d9a2fcfd3cb5f537 (diff) | |
Update struct poly params formatting to match proc params and wrap
struct fields in a group
| -rw-r--r-- | src/odin/printer/visit.odin | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 4d1a3af..5640016 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1575,7 +1575,21 @@ visit_expr :: proc( case ^Struct_Type: document = text_position(p, "struct", v.pos) - document = cons(document, visit_poly_params(p, v.poly_params)) + if v.poly_params != nil { + document = cons(document, text("(")) + document = cons( + document, + nest( + cons( + break_with(""), + visit_signature_list(p, v.poly_params, false, false, options), + ), + ), + ) + document = cons(document, break_with(""), text(")")) + } else { + document = cons(document, empty()) + } if v.is_packed { document = cons_with_nopl(document, text("#packed")) @@ -1619,7 +1633,9 @@ visit_expr :: proc( nest( cons( newline_position(p, 1, v.fields.open), - visit_struct_field_list(p, v.fields, {.Add_Comma, .Trailing, .Enforce_Newline}), + group( + visit_struct_field_list(p, v.fields, {.Add_Comma, .Trailing, .Enforce_Newline}) + ), ), ), ) |