diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-26 20:15:34 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-26 20:15:34 -0400 |
| commit | 8244c527778d082fc3bc8a219bbaa23d3a8b11ea (patch) | |
| tree | 88a2c03f4f6a29106c94f8ac689f2cdcf4e4ae2d | |
| parent | e211cdcdb8f6ab65fffb24552b89956c06f150cb (diff) | |
| parent | 0d767601f59dbe3e700047f6bc3937daa346c148 (diff) | |
Merge pull request #931 from BradLewis/fix/long-value-decl-types
Correctly format types with a long value decl
| -rw-r--r-- | src/odin/printer/visit.odin | 13 | ||||
| -rw-r--r-- | tools/odinfmt/tests/.snapshots/procedures.odin | 9 | ||||
| -rw-r--r-- | tools/odinfmt/tests/procedures.odin | 3 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 1adc276..2b948a5 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -340,13 +340,12 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) -> ^Do rhs = cons_with_nopl(rhs, visit_exprs(p, v.values, {.Add_Comma}, .Value_Decl)) } else if len(v.values) > 0 && v.type != nil { - rhs = cons_with_nopl( - rhs, - cons_with_nopl( - text(" :" if p.config.spaces_around_colons else ":"), - visit_exprs(p, v.values, {.Add_Comma}), - ), - ) + if v.type != nil { + lhs = cons_with_nopl(lhs, text(":")) + } else { + lhs = cons(lhs, text(":")) + } + rhs = cons_with_nopl(rhs, visit_exprs(p, v.values, {.Add_Comma})) } else { rhs = cons_with_nopl(rhs, visit_exprs(p, v.values, {.Add_Comma}, .Value_Decl)) } diff --git a/tools/odinfmt/tests/.snapshots/procedures.odin b/tools/odinfmt/tests/.snapshots/procedures.odin index 791439d..43848bd 100644 --- a/tools/odinfmt/tests/.snapshots/procedures.odin +++ b/tools/odinfmt/tests/.snapshots/procedures.odin @@ -12,3 +12,12 @@ tracking_allocator_check_leaks :: proc( } + +init: proc( + window_width: int, + window_height: int, + window_title: string, + allocator := context.allocator, + loc := #caller_location, + ) -> ^State : + _init diff --git a/tools/odinfmt/tests/procedures.odin b/tools/odinfmt/tests/procedures.odin index 3cd54f1..effd076 100644 --- a/tools/odinfmt/tests/procedures.odin +++ b/tools/odinfmt/tests/procedures.odin @@ -8,3 +8,6 @@ tracking_allocator_check_leaks :: proc(tracking_allocator: ^mem.Tracking_Allocat } + +init: proc(window_width: int, window_height: int, window_title: string, + allocator := context.allocator, loc := #caller_location) -> ^State : _init |