Merge pull request #166 from hashicorp/b-comment-indent
hcl/printer: multiline comments shouldn't indent lines 2+
This commit is contained in:
commit
3d702911d9
@ -288,7 +288,7 @@ func (p *printer) objectType(o *ast.ObjectType) []byte {
|
|||||||
buf.WriteByte(newline)
|
buf.WriteByte(newline)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.Write(p.indent([]byte(comment.Text)))
|
buf.Write(p.indent(p.heredocIndent([]byte(comment.Text))))
|
||||||
buf.WriteByte(newline)
|
buf.WriteByte(newline)
|
||||||
if index != len(o.List.Items) {
|
if index != len(o.List.Items) {
|
||||||
buf.WriteByte(newline) // do not print on the end
|
buf.WriteByte(newline) // do not print on the end
|
||||||
|
@ -34,6 +34,7 @@ var data = []entry{
|
|||||||
{"comment.input", "comment.golden"},
|
{"comment.input", "comment.golden"},
|
||||||
{"comment_aligned.input", "comment_aligned.golden"},
|
{"comment_aligned.input", "comment_aligned.golden"},
|
||||||
{"comment_array.input", "comment_array.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_no_stanza.input", "comment_multiline_no_stanza.golden"},
|
||||||
{"comment_multiline_stanza.input", "comment_multiline_stanza.golden"},
|
{"comment_multiline_stanza.input", "comment_multiline_stanza.golden"},
|
||||||
{"comment_newline.input", "comment_newline.golden"},
|
{"comment_newline.input", "comment_newline.golden"},
|
||||||
|
12
hcl/printer/testdata/comment_multiline_indent.golden
vendored
Normal file
12
hcl/printer/testdata/comment_multiline_indent.golden
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
resource "provider" "resource" {
|
||||||
|
/*
|
||||||
|
SPACE_SENSITIVE_CODE = <<EOF
|
||||||
|
yaml code:
|
||||||
|
foo: ""
|
||||||
|
bar: ""
|
||||||
|
EOF
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
OTHER
|
||||||
|
*/
|
||||||
|
}
|
13
hcl/printer/testdata/comment_multiline_indent.input
vendored
Normal file
13
hcl/printer/testdata/comment_multiline_indent.input
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
resource "provider" "resource" {
|
||||||
|
/*
|
||||||
|
SPACE_SENSITIVE_CODE = <<EOF
|
||||||
|
yaml code:
|
||||||
|
foo: ""
|
||||||
|
bar: ""
|
||||||
|
EOF
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
OTHER
|
||||||
|
*/
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user