From cab61b36dc33e14a8776d9dbd6668aadb892520a Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sat, 24 Jun 2017 09:08:49 -0700 Subject: [PATCH] zclwrite: format shouldn't add spaces around attribute access dots --- zclwrite/format.go | 4 ++++ zclwrite/format_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/zclwrite/format.go b/zclwrite/format.go index b9eb7e9..5f72116 100644 --- a/zclwrite/format.go +++ b/zclwrite/format.go @@ -231,6 +231,10 @@ func spaceAfterToken(subject, before, after *Token) bool { // Don't split a function name from open paren in a call return false + case subject.Type == zclsyntax.TokenDot || after.Type == zclsyntax.TokenDot: + // Don't use spaces around attribute access dots + return false + case after.Type == zclsyntax.TokenComma: // No space right before a comma in an argument list return false diff --git a/zclwrite/format_test.go b/zclwrite/format_test.go index 673f5ed..1824afb 100644 --- a/zclwrite/format_test.go +++ b/zclwrite/format_test.go @@ -23,6 +23,10 @@ func TestFormat(t *testing.T) { `a=1`, `a = 1`, }, + { + `a=b.c`, + `a = b.c`, + }, { `( a+2 )`, `(a + 2)`,