From 81c607a115c9c987cd31bf76413108c30319db1b Mon Sep 17 00:00:00 2001 From: sobaya Date: Thu, 1 Aug 2019 16:58:41 +0900 Subject: [PATCH] Fix: extrace space after first field --- src/dfmt/formatter.d | 3 ++- tests/allman/issue0256.d.ref | 4 ++-- tests/otbs/issue0256.d.ref | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 56fc27a..3f6d1c7 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -749,7 +749,8 @@ private: } else if (peekBackIs(tok!"identifier") && (peekBack2Is(tok!"{", true) || peekBack2Is(tok!"}", true) || peekBack2Is(tok!";", true) - || peekBack2Is(tok!":", true)) && !(isBlockHeader(1) && !peekIs(tok!"if"))) + || peekBack2Is(tok!":", true) || peekBack2Is(tok!",", true)) + && !(isBlockHeader(1) && !peekIs(tok!"if"))) { writeToken(); if (isStructInitializer) diff --git a/tests/allman/issue0256.d.ref b/tests/allman/issue0256.d.ref index 2003daf..0a18239 100644 --- a/tests/allman/issue0256.d.ref +++ b/tests/allman/issue0256.d.ref @@ -1,6 +1,6 @@ void foo() { S s1 = {a: 3}; - S s2 = {a: 3, b : "test string"}; - S s3 = {a: 3, b : "test string", c : {x: 3.14, y : 3 + 4}}; + S s2 = {a: 3, b: "test string"}; + S s3 = {a: 3, b: "test string", c: {x: 3.14, y: 3 + 4}}; } diff --git a/tests/otbs/issue0256.d.ref b/tests/otbs/issue0256.d.ref index ed62ae0..576e0bd 100644 --- a/tests/otbs/issue0256.d.ref +++ b/tests/otbs/issue0256.d.ref @@ -1,5 +1,5 @@ void foo() { S s1 = {a: 3}; - S s2 = {a: 3, b : "test string"}; - S s3 = {a: 3, b : "test string", c : {x: 3.14, y : 3 + 4}}; + S s2 = {a: 3, b: "test string"}; + S s3 = {a: 3, b: "test string", c: {x: 3.14, y: 3 + 4}}; }