aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-01-20 22:13:36 +0100
committerDanielGavin <danielgavin5@hotmail.com>2024-01-20 22:13:36 +0100
commitc01c4b0e9b92fbcfb17f459a89a7fa3de14f1eff (patch)
treeee36b9ce42cb31a99149905444cf3ecf08a8cae7 /src
parent222b8aae0f78210939013ed1592b63b7300636a1 (diff)
Align bitsets in comp literals.
Diffstat (limited to 'src')
-rw-r--r--src/odin/printer/visit.odin10
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))