hclwrite: do not add space after a boolean NOT operator
This commit is contained in:
parent
6a747c8a53
commit
61e260fbae
@ -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):
|
case after.Type == hclsyntax.TokenOBrack && (subject.Type == hclsyntax.TokenIdent || subject.Type == hclsyntax.TokenNumberLit || tokenBracketChange(subject) < 0):
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
case subject.Type == hclsyntax.TokenBang:
|
||||||
|
// No space after a bang
|
||||||
|
return false
|
||||||
|
|
||||||
case subject.Type == hclsyntax.TokenMinus:
|
case subject.Type == hclsyntax.TokenMinus:
|
||||||
// Since a minus can either be subtraction or negation, and the latter
|
// 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
|
// should _not_ have a space after it, we need to use some heuristics
|
||||||
|
@ -67,6 +67,10 @@ func TestFormat(t *testing.T) {
|
|||||||
`foo(a,b...)`,
|
`foo(a,b...)`,
|
||||||
`foo(a, b...)`,
|
`foo(a, b...)`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`! true`,
|
||||||
|
`!true`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
`a="hello ${ name }"`,
|
`a="hello ${ name }"`,
|
||||||
`a = "hello ${name}"`,
|
`a = "hello ${name}"`,
|
||||||
|
Loading…
Reference in New Issue
Block a user