mirror of
https://github.com/caddyserver/caddy.git
synced 2026-11-17 05:26:15 +00:00
* caddyfile: Keep an opening brace that ends the input
Format writes an opening brace lazily: the '{' case records the pending
brace and continues, and the brace is only emitted once a following
regular character is processed. When the input ends while a brace is
still pending, the read loop exits and nothing flushes it, so the brace
is dropped. 'caddy fmt' on a Caddyfile whose last line has just opened a
block therefore deletes the brace the user typed, and with --overwrite
that result is written back over the file.
Flush a pending brace after the loop ends. This also restores
idempotence for inputs such as '{ {', which formatted to '{' and then to
nothing.
* caddyfile: Flush a pending brace before another one replaces it
The '{' case overwrote the pending-brace state without emitting the
brace already waiting, so adjacent braces lost one: Format("{{") gave
just "{". Only the space-separated path flushed, and it did so with an
inline block.
Move that block into a flushOpenBrace closure and call it from the three
places a pending brace has to be emitted: the existing space-separated
path, the '{' case before it replaces the state, and the end of input.
Using it at the end of input also indents a trailing brace the same way
the other paths do.
|
||
|---|---|---|
| .. | ||
| caddyfile | ||
| httpcaddyfile | ||
| warning | ||
| configadapters.go | ||
| httploader.go | ||
| httploader_test.go | ||
| load.go | ||