From 635f075f187ac73c65e6939b8402494469a4d627 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 16 Dec 2020 15:22:16 -0700 Subject: caddyfile: Fix minor bug in formatter --- caddyconfig/caddyfile/formatter.go | 2 ++ caddyconfig/caddyfile/formatter_test.go | 11 +++++++++++ 2 files changed, 13 insertions(+) (limited to 'caddyconfig/caddyfile') 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 -- cgit v1.2.3