Skip to content

Commit

Permalink
std/render: Prefer wrapping with push/pop instead of using pushIndent…
Browse files Browse the repository at this point in the history
…OneShot
  • Loading branch information
87flowers committed Oct 15, 2024
1 parent ea527f7 commit 886cf73
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/std/zig/render.zig
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
try renderToken(r, main_token, after_op_space); // catch keyword
}

ais.pushIndentOneShot();
ais.pushIndent();
try renderExpression(r, datas[node].rhs, space); // fallback
ais.popIndent();
},

.field_access => {
Expand Down Expand Up @@ -564,8 +565,9 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
try renderToken(r, op_token, .newline);
ais.popIndent();
}
ais.pushIndentOneShot();
return renderExpression(r, infix.rhs, space);
ais.pushIndent();
try renderExpression(r, infix.rhs, space);
ais.popIndent();
},

.assign_destructure => {
Expand Down Expand Up @@ -594,8 +596,9 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
try renderToken(r, full.ast.equal_token, .newline);
ais.popIndent();
}
ais.pushIndentOneShot();
return renderExpression(r, full.ast.value_expr, space);
ais.pushIndent();
try renderExpression(r, full.ast.value_expr, space);
ais.popIndent();
},

.bit_not,
Expand Down Expand Up @@ -1243,8 +1246,9 @@ fn renderVarDeclWithoutFixups(
try renderToken(r, eq_token, eq_space); // =
ais.popIndent();
}
ais.pushIndentOneShot();
return renderExpression(r, var_decl.ast.init_node, space); // ;
ais.pushIndent();
try renderExpression(r, var_decl.ast.init_node, space); // ;
ais.popIndent();
}

fn renderIf(r: *Render, if_node: Ast.full.If, space: Space) Error!void {
Expand Down

0 comments on commit 886cf73

Please sign in to comment.