diff options
| author | Martin Atkins <mart@degeneration.co.uk> | 2018-12-14 15:53:02 -0800 |
|---|---|---|
| committer | Martin Atkins <mart@degeneration.co.uk> | 2018-12-14 15:53:02 -0800 |
| commit | dac4796ca1468257e064e5be7626198bbf85aa17 (patch) | |
| tree | 7eb64bd83ad2df1bf63da9c327dd8f5988e8aa93 /hclwrite | |
| parent | 4c4fdbdcc016df0562391a71965701efa4a1408c (diff) | |
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.
Diffstat (limited to 'hclwrite')
| -rw-r--r-- | hclwrite/format.go | 4 | ||||
| -rw-r--r-- | hclwrite/format_test.go | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/hclwrite/format.go b/hclwrite/format.go index ad17121..ef50e09 100644 --- a/hclwrite/format.go +++ b/hclwrite/format.go @@ -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 diff --git a/hclwrite/format_test.go b/hclwrite/format_test.go index 9106466..b4783c2 100644 --- a/hclwrite/format_test.go +++ b/hclwrite/format_test.go @@ -108,16 +108,20 @@ 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]`, }, { ` |
