Skip to content

Commit

Permalink
Align bitsets in comp literals.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGavin committed Jan 20, 2024
1 parent 222b8aa commit c01c4b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/odin/printer/visit.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit c01c4b0

Please sign in to comment.