aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2023-07-25 00:24:13 +0200
committerDanielGavin <danielgavin5@hotmail.com>2023-07-25 00:24:13 +0200
commit4cd60bba6df6691b916124f1ba1b6fc6f7d15496 (patch)
tree26847ac08b3cb4765a6dc3bd4e46c9f01cc0e2d4 /src
parent261f4a2fc416fb29a32d1fabbf6d111d4c116518 (diff)
Enforce brackets in indexing - it just doesn't look right when broken down.
Diffstat (limited to 'src')
-rw-r--r--src/odin/printer/visit.odin23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin
index e54dafc..3e71b0a 100644
--- a/src/odin/printer/visit.odin
+++ b/src/odin/printer/visit.odin
@@ -1921,18 +1921,21 @@ visit_expr :: proc(
cons(text("("), nest(visit_expr(p, v.expr)), text(")")),
)
case ^Index_Expr:
- document = cons(
- visit_expr(p, v.expr),
- text("["),
- nest(
- cons(
- break_with("", true),
- group(visit_expr(p, v.index)),
- if_break(" \\"),
+ //Switch back to enforce fit, it just doesn't look good when breaking.
+ document = enforce_fit(
+ cons(
+ visit_expr(p, v.expr),
+ text("["),
+ nest(
+ cons(
+ break_with("", true),
+ group(visit_expr(p, v.index)),
+ if_break(" \\"),
+ ),
),
+ break_with("", true),
+ text("]"),
),
- break_with("", true),
- text("]"),
)
case ^Proc_Group:
document = text_token(p, v.tok)