Merge pull request #85 from VladRassokhin/fix-list-comments-indent
Fix indent of list item comments
This commit is contained in:
commit
a01f759c89
@ -434,12 +434,8 @@ func (p *printer) list(l *ast.ListType) []byte {
|
||||
if lit, ok := item.(*ast.LiteralType); ok && lit.LineComment != nil {
|
||||
// if the next item doesn't have any comments, do not align
|
||||
buf.WriteByte(blank) // align one space
|
||||
if i != len(l.List)-1 {
|
||||
if lit, ok := l.List[i+1].(*ast.LiteralType); ok && lit.LineComment != nil {
|
||||
for i := 0; i < longestLine-curLen; i++ {
|
||||
buf.WriteByte(blank)
|
||||
}
|
||||
}
|
||||
for i := 0; i < longestLine-curLen; i++ {
|
||||
buf.WriteByte(blank)
|
||||
}
|
||||
|
||||
for _, comment := range lit.LineComment.List {
|
||||
|
7
hcl/printer/testdata/comment_aligned.golden
vendored
7
hcl/printer/testdata/comment_aligned.golden
vendored
@ -22,4 +22,11 @@ aligned {
|
||||
"foo", # kenya 1
|
||||
"${aws_security_group.firewall.foo}", # kenya 2
|
||||
]
|
||||
|
||||
security_groups2 = [
|
||||
"foo", # kenya 1
|
||||
"bar", # kenya 1.5
|
||||
"${aws_security_group.firewall.foo}", # kenya 2
|
||||
"foobar", # kenya 3
|
||||
]
|
||||
}
|
7
hcl/printer/testdata/comment_aligned.input
vendored
7
hcl/printer/testdata/comment_aligned.input
vendored
@ -18,4 +18,11 @@ security_groups = [
|
||||
"foo", # kenya 1
|
||||
"${aws_security_group.firewall.foo}", # kenya 2
|
||||
]
|
||||
|
||||
security_groups2 = [
|
||||
"foo", # kenya 1
|
||||
"bar", # kenya 1.5
|
||||
"${aws_security_group.firewall.foo}", # kenya 2
|
||||
"foobar", # kenya 3
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user