caddyfile: Fix minor bug in formatter

This commit is contained in:
Matthew Holt 2020-12-16 15:22:16 -07:00
parent e384f07a3c
commit 635f075f18
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
2 changed files with 13 additions and 0 deletions

View file

@ -78,6 +78,8 @@ func Format(input []byte) []byte {
if comment { if comment {
if ch == '\n' { if ch == '\n' {
comment = false comment = false
nextLine()
continue
} else { } else {
write(ch) write(ch)
continue continue

View file

@ -310,6 +310,17 @@ baz`,
input: `redir / /some/#/path`, input: `redir / /some/#/path`,
expect: `redir / /some/#/path`, expect: `redir / /some/#/path`,
}, },
{
description: "brace does not fold into comment above",
input: `# comment
{
foo
}`,
expect: `# comment
{
foo
}`,
},
} { } {
// the formatter should output a trailing newline, // the formatter should output a trailing newline,
// even if the tests aren't written to expect that // even if the tests aren't written to expect that