Merge pull request #166 from hashicorp/b-comment-indent

hcl/printer: multiline comments shouldn't indent lines 2+
This commit is contained in:
Mitchell Hashimoto 2016-11-09 14:51:35 -08:00 committed by GitHub
commit 3d702911d9
4 changed files with 27 additions and 1 deletions

View File

@ -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

View File

@ -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"},

View File

@ -0,0 +1,12 @@
resource "provider" "resource" {
/*
SPACE_SENSITIVE_CODE = <<EOF
yaml code:
foo: ""
bar: ""
EOF
*/
/*
OTHER
*/
}

View File

@ -0,0 +1,13 @@
resource "provider" "resource" {
/*
SPACE_SENSITIVE_CODE = <<EOF
yaml code:
foo: ""
bar: ""
EOF
*/
/*
OTHER
*/
}