hclwrite: Formatter to put spaces before colons

The symmetrical spaces around colons in conditionals are important for
familiarity with C-like languages, so we'll instead accept spaces around
colons in our HCL2-unique "for expression" construct.
This commit is contained in:
Martin Atkins 2018-12-14 15:53:02 -08:00
parent 4c4fdbdcc0
commit dac4796ca1
2 changed files with 8 additions and 8 deletions

View File

@ -316,10 +316,6 @@ func spaceAfterToken(subject, before, after *Token) bool {
}
return true
case after.Type == hclsyntax.TokenColon:
// Never spaces before colons
return false
// In the unlikely event that an interpolation expression is just
// a single object constructor, we'll put a space between the ${ and
// the following { to make this more obvious, and then the same

View File

@ -107,17 +107,21 @@ foo(
)
`,
},
{
`a?b:c`,
`a ? b : c`,
},
{
`[ [ ] ]`,
`[[]]`,
},
{
`[for x in y: x]`,
`[for x in y: x]`,
`[for x in y : x]`,
`[for x in y : x]`,
},
{
`[for x in [y]: x]`,
`[for x in [y]: x]`,
`[for x in [y] : x]`,
`[for x in [y] : x]`,
},
{
`