aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2023-09-20 22:38:40 +0200
committerDanielGavin <danielgavin5@hotmail.com>2023-09-20 22:38:40 +0200
commit61e33aa13f25c9b8f4e8e9087a4c482a484b3bf8 (patch)
tree277534bd8a7c346fc4c637122a1dd9ccc5a33058 /src
parent44eab3849a646fdf4af81c18fafb0a6b448aa709 (diff)
Fix issue with formatting where clause not breaking.
Diffstat (limited to 'src')
-rw-r--r--src/odin/printer/visit.odin24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin
index edc1403..6e9a7f7 100644
--- a/src/odin/printer/visit.odin
+++ b/src/odin/printer/visit.odin
@@ -1499,17 +1499,15 @@ contains_do_in_expression :: proc(p: ^Printer, expr: ^ast.Expr) -> bool {
}
@(private)
-push_where_clauses :: proc(p: ^Printer, clauses: []^ast.Expr) -> ^Document {
+visit_where_clauses :: proc(p: ^Printer, clauses: []^ast.Expr) -> ^Document {
if len(clauses) == 0 {
return empty()
}
- return group(
- nest(
- cons_with_nopl(
- text("where"),
- visit_exprs(p, clauses, {.Add_Comma, .Enforce_Newline}),
- ),
+ return nest(
+ cons_with_nopl(
+ text("where"),
+ visit_exprs(p, clauses, {.Add_Comma, .Enforce_Newline}),
),
)
}
@@ -1699,7 +1697,7 @@ visit_expr :: proc(
document = cons_with_nopl(
document,
- push_where_clauses(p, v.where_clauses),
+ visit_where_clauses(p, v.where_clauses),
)
if len(v.variants) == 0 {
@@ -1784,7 +1782,7 @@ visit_expr :: proc(
document = cons_with_nopl(
document,
- push_where_clauses(p, v.where_clauses),
+ visit_where_clauses(p, v.where_clauses),
)
if v.fields != nil && len(v.fields.list) == 0 {
@@ -1834,10 +1832,14 @@ visit_expr :: proc(
document,
visit_proc_type(p, v.type^, v.body != nil),
)
+
document = cons_with_nopl(
document,
- push_where_clauses(p, v.where_clauses),
+ visit_where_clauses(p, v.where_clauses),
)
+
+ document = group(document)
+
document = cons(document, visit_proc_tags(p, v.tags))
if v.body != nil {
@@ -2513,7 +2515,7 @@ visit_proc_type :: proc(
document = cons_with_nopl(document, text("!"))
}
- return group(document)
+ return document
}