summaryrefslogtreecommitdiff
path: root/hclwrite
diff options
context:
space:
mode:
authorVarun Sivapalan <5470233+sivapalan@users.noreply.github.com>2020-12-03 01:10:12 +0100
committerGitHub <noreply@github.com>2020-12-02 16:10:12 -0800
commit61e260fbae097fa927cbbf00be6c4cc9863a30c4 (patch)
treebb78090db8cdd84430329461d98a9f8f5a3d584e /hclwrite
parent6a747c8a53944fbc3f2057ac6da2c9433ff136ed (diff)
hclwrite: do not add space after a boolean NOT operator
Diffstat (limited to 'hclwrite')
-rw-r--r--hclwrite/format.go4
-rw-r--r--hclwrite/format_test.go4
2 files changed, 8 insertions, 0 deletions
diff --git a/hclwrite/format.go b/hclwrite/format.go
index b94bee3..2b4ba32 100644
--- a/hclwrite/format.go
+++ b/hclwrite/format.go
@@ -263,6 +263,10 @@ func spaceAfterToken(subject, before, after *Token) bool {
case after.Type == hclsyntax.TokenOBrack && (subject.Type == hclsyntax.TokenIdent || subject.Type == hclsyntax.TokenNumberLit || tokenBracketChange(subject) < 0):
return false
+ case subject.Type == hclsyntax.TokenBang:
+ // No space after a bang
+ return false
+
case subject.Type == hclsyntax.TokenMinus:
// Since a minus can either be subtraction or negation, and the latter
// should _not_ have a space after it, we need to use some heuristics
diff --git a/hclwrite/format_test.go b/hclwrite/format_test.go
index 241cc7a..037157a 100644
--- a/hclwrite/format_test.go
+++ b/hclwrite/format_test.go
@@ -68,6 +68,10 @@ func TestFormat(t *testing.T) {
`foo(a, b...)`,
},
{
+ `! true`,
+ `!true`,
+ },
+ {
`a="hello ${ name }"`,
`a = "hello ${name}"`,
},