Skip to content

Commit

Permalink
Merge pull request hashicorp#166 from hashicorp/b-comment-indent
Browse files Browse the repository at this point in the history
hcl/printer: multiline comments shouldn't indent lines 2+
  • Loading branch information
mitchellh committed Nov 9, 2016
2 parents 973f376 + be7f043 commit 3d70291
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hcl/printer/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (p *printer) objectType(o *ast.ObjectType) []byte {
buf.WriteByte(newline)
}

buf.Write(p.indent([]byte(comment.Text)))
buf.Write(p.indent(p.heredocIndent([]byte(comment.Text))))
buf.WriteByte(newline)
if index != len(o.List.Items) {
buf.WriteByte(newline) // do not print on the end
Expand Down
1 change: 1 addition & 0 deletions hcl/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var data = []entry{
{"comment.input", "comment.golden"},
{"comment_aligned.input", "comment_aligned.golden"},
{"comment_array.input", "comment_array.golden"},
{"comment_multiline_indent.input", "comment_multiline_indent.golden"},
{"comment_multiline_no_stanza.input", "comment_multiline_no_stanza.golden"},
{"comment_multiline_stanza.input", "comment_multiline_stanza.golden"},
{"comment_newline.input", "comment_newline.golden"},
Expand Down
12 changes: 12 additions & 0 deletions hcl/printer/testdata/comment_multiline_indent.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "provider" "resource" {
/*
SPACE_SENSITIVE_CODE = <<EOF
yaml code:
foo: ""
bar: ""
EOF
*/
/*
OTHER
*/
}
13 changes: 13 additions & 0 deletions hcl/printer/testdata/comment_multiline_indent.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "provider" "resource" {
/*
SPACE_SENSITIVE_CODE = <<EOF
yaml code:
foo: ""
bar: ""
EOF
*/

/*
OTHER
*/
}

0 comments on commit 3d70291

Please sign in to comment.