diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-02-03 12:52:14 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-02-03 12:52:14 +0100 |
| commit | 7c9bfc7bbfa05cace89efc39c946bd90229dba2d (patch) | |
| tree | 496a1ce75b9f87613bd5420c477c809195c86785 /src | |
| parent | d3fd20e81162cbf3c41b4a7299d36ab56f72fae7 (diff) | |
| parent | d93559abe647e733b0338cf0707aba09c350481a (diff) | |
Merge branch 'master' into poly
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/visit.odin | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index e7bdda9..a153df5 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1438,7 +1438,7 @@ should_align_comp_lit :: proc(p: ^Printer, comp_lit: ast.Comp_Lit) -> bool { } @(private) -comp_lit_contains_fields :: proc(p: ^Printer, comp_lit: ast.Comp_Lit) -> bool { +comp_lit_contains_fields :: proc(comp_lit: ast.Comp_Lit) -> bool { if len(comp_lit.elems) == 0 { return false @@ -2051,7 +2051,7 @@ visit_expr :: proc( } should_newline := - comp_lit_contains_fields(p, v^) || + comp_lit_contains_fields(v^) || contains_comments_in_range(p, v.pos, v.end) should_newline &= (called_from == .Value_Decl || @@ -2807,8 +2807,10 @@ get_possible_comp_lit_alignment :: proc(exprs: []^ast.Expr) -> int { return 0 } - if _, is_comp := value.value.derived.(^ast.Comp_Lit); is_comp { - return 0 + if comp, is_comp := value.value.derived.(^ast.Comp_Lit); is_comp { + if comp_lit_contains_fields(comp^) { + return 0 + } } longest_name = max(longest_name, get_node_length(value.field)) |