summaryrefslogtreecommitdiff
path: root/caddyconfig/caddyfile
diff options
context:
space:
mode:
Diffstat (limited to 'caddyconfig/caddyfile')
-rw-r--r--caddyconfig/caddyfile/formatter.go2
-rw-r--r--caddyconfig/caddyfile/formatter_test.go11
2 files changed, 13 insertions, 0 deletions
diff --git a/caddyconfig/caddyfile/formatter.go b/caddyconfig/caddyfile/formatter.go
index 6270541..8620219 100644
--- a/caddyconfig/caddyfile/formatter.go
+++ b/caddyconfig/caddyfile/formatter.go
@@ -78,6 +78,8 @@ func Format(input []byte) []byte {
if comment {
if ch == '\n' {
comment = false
+ nextLine()
+ continue
} else {
write(ch)
continue
diff --git a/caddyconfig/caddyfile/formatter_test.go b/caddyconfig/caddyfile/formatter_test.go
index 6751eca..6cae20d 100644
--- a/caddyconfig/caddyfile/formatter_test.go
+++ b/caddyconfig/caddyfile/formatter_test.go
@@ -310,6 +310,17 @@ baz`,
input: `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,
// even if the tests aren't written to expect that