summaryrefslogtreecommitdiff
path: root/caddyconfig
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-12-16 15:22:16 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2020-12-16 15:22:16 -0700
commit635f075f187ac73c65e6939b8402494469a4d627 (patch)
treed025aabaf43a5b2bcdfc5828bfb7bd01bb1ff3ea /caddyconfig
parente384f07a3ce91ddbc8c4d4344f03a0dafe3df9f3 (diff)
caddyfile: Fix minor bug in formatter
Diffstat (limited to 'caddyconfig')
-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