From c01c4b0e9b92fbcfb17f459a89a7fa3de14f1eff Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sat, 20 Jan 2024 22:13:36 +0100 Subject: Align bitsets in comp literals. --- src/odin/printer/visit.odin | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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)) -- cgit v1.2.3