From d30208ee1f4c3c84ee45a95914b8b2edd7635981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Tr=C3=A9guier?= Date: Sun, 7 Oct 2018 14:41:21 +0200 Subject: [PATCH] Fix enum constants wrapping --- src/dfmt/formatter.d | 6 ++++-- tests/allman/issue0286.d.ref | 4 ++-- tests/otbs/issue0286.d.ref | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 730ef48..7219123 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -1314,7 +1314,8 @@ private: { if (isWrapToken) { - pushWrapIndent(); + if (!indents.topIs(tok!"enum")) + pushWrapIndent(); write(" "); writeToken(); newline(); @@ -1331,7 +1332,8 @@ private: { if (isWrapToken) { - pushWrapIndent(); + if (!indents.topIs(tok!"enum")) + pushWrapIndent(); newline(); writeToken(); } diff --git a/tests/allman/issue0286.d.ref b/tests/allman/issue0286.d.ref index d3e7816..1ee7afb 100644 --- a/tests/allman/issue0286.d.ref +++ b/tests/allman/issue0286.d.ref @@ -2,14 +2,14 @@ void foo() { if (true) enum vectorizeable = aLongExpressionThatCausesWrapping() - && aLongExpressionThatCausesWrapping(); + && aLongExpressionThatCausesWrapping(); else enum vectorizeable = false; if (true) { enum vectorizeable = aLongExpressionThatCausesWrapping() - && aLongExpressionThatCausesWrapping(); + && aLongExpressionThatCausesWrapping(); } else enum vectorizeable = false; diff --git a/tests/otbs/issue0286.d.ref b/tests/otbs/issue0286.d.ref index 1844006..a56988e 100644 --- a/tests/otbs/issue0286.d.ref +++ b/tests/otbs/issue0286.d.ref @@ -1,13 +1,13 @@ void foo() { if (true) enum vectorizeable = aLongExpressionThatCausesWrapping() - && aLongExpressionThatCausesWrapping(); + && aLongExpressionThatCausesWrapping(); else enum vectorizeable = false; if (true) { enum vectorizeable = aLongExpressionThatCausesWrapping() - && aLongExpressionThatCausesWrapping(); + && aLongExpressionThatCausesWrapping(); } else enum vectorizeable = false; }