summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--caddyconfig/caddyfile/formatter.go1
-rw-r--r--caddyconfig/caddyfile/formatter_test.go38
-rw-r--r--modules/caddyhttp/replacer_test.go2
3 files changed, 40 insertions, 1 deletions
diff --git a/caddyconfig/caddyfile/formatter.go b/caddyconfig/caddyfile/formatter.go
index 8620219..cb0033f 100644
--- a/caddyconfig/caddyfile/formatter.go
+++ b/caddyconfig/caddyfile/formatter.go
@@ -78,6 +78,7 @@ func Format(input []byte) []byte {
if comment {
if ch == '\n' {
comment = false
+ space = true
nextLine()
continue
} else {
diff --git a/caddyconfig/caddyfile/formatter_test.go b/caddyconfig/caddyfile/formatter_test.go
index 6cae20d..64cf6d2 100644
--- a/caddyconfig/caddyfile/formatter_test.go
+++ b/caddyconfig/caddyfile/formatter_test.go
@@ -321,6 +321,44 @@ baz`,
foo
}`,
},
+ {
+ description: "matthewpi/vscode-caddyfile-support#13",
+ input: `{
+ email {$ACMEEMAIL}
+ #debug
+}
+
+block {
+}
+`,
+ expect: `{
+ email {$ACMEEMAIL}
+ #debug
+}
+
+block {
+}
+`,
+ },
+ {
+ description: "matthewpi/vscode-caddyfile-support#13 - bad formatting",
+ input: `{
+ email {$ACMEEMAIL}
+ #debug
+ }
+
+ block {
+ }
+`,
+ expect: `{
+ email {$ACMEEMAIL}
+ #debug
+}
+
+block {
+}
+`,
+ },
} {
// the formatter should output a trailing newline,
// even if the tests aren't written to expect that
diff --git a/modules/caddyhttp/replacer_test.go b/modules/caddyhttp/replacer_test.go
index 486a8e3..5026ac8 100644
--- a/modules/caddyhttp/replacer_test.go
+++ b/modules/caddyhttp/replacer_test.go
@@ -173,7 +173,7 @@ eqp31wM9il1n+guTNyxJd+FzVAH+hCZE5K+tCgVDdVFUlDEHHbS/wqb2PSIoouLV
},
{
input: "{http.request.tls.client.certificate_pem}",
- expect: string(clientCert) + "\n", // returned value comes with a newline appended to it
+ expect: string(clientCert) + "\n", // returned value comes with a newline appended to it
},
} {
actual := repl.ReplaceAll(tc.input, "<empty>")