# zig fmt: simplify and improve consistency of if/for/while handling · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/48efa3bcb678ac2f869554b4c5383f865ad73a33)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 48efa3bcb678ac2f869554b4c5383f865ad73a33

Requested commit: 48efa3bcb678ac2f869554b4c5383f865ad73a33

Commit: 48efa3bcb678ac2f869554b4c5383f865ad73a33

Tree: 15bf7ad888efba6fef3f514f2a501c5129e68ef6

Author: Isaac Freund

Committer: Isaac Freund

## Message

```
zig fmt: simplify and improve consistency of if/for/while handling

The main realization here was that getting rid of the early returns
in renderWhile() and rewriting the logic into a mostly unified execution
path took things from ~200 lines to ~100 lines and improved consistency
by deduplicating code.

Also add several test cases and fix a few issues along the way:

Fixes https://github.com/ziglang/zig/issues/6114
Fixes https://github.com/ziglang/zig/issues/8022

```

## Parents

- [b4db03d8bb29f0cded857300df460b4247e85670](https://git.cafe/gitcafe/zig/commit/b4db03d8bb29f0cded857300df460b4247e85670?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/48efa3bcb678ac2f869554b4c5383f865ad73a33?format=markdown)
