From dba8c87ebc8c22e4cbba5a6b1a5caf18a16233a5 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 25 Jan 2023 12:32:02 +0100 Subject: [PATCH] Revert operator indentation in an argument list --- src/dfmt/formatter.d | 4 +-- tests/allman/argument_chain_indent.d.ref | 10 ++++++ tests/allman/argument_chain_keep_breaks.d.ref | 16 ++++++++++ tests/argument_chain_indent.d | 32 +++++++++++++++++++ tests/argument_chain_keep_breaks.d | 16 ++++++++++ tests/knr/argument_chain_indent.d.ref | 10 ++++++ tests/knr/argument_chain_keep_breaks.d.ref | 16 ++++++++++ tests/otbs/argument_chain_indent.d.ref | 10 ++++++ tests/otbs/argument_chain_keep_breaks.d.ref | 16 ++++++++++ 9 files changed, 128 insertions(+), 2 deletions(-) diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index c123f0e..e5638e1 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -1625,7 +1625,7 @@ private: const commaLine = tokens[index].line; writeToken(); - if (indents.topIs(tok!".")) + if (indents.topIsWrap && !indents.topIs(tok!",")) { indents.pop; } @@ -1647,7 +1647,7 @@ private: { pushWrapIndent(); writeToken(); - if (indents.topIs(tok!".")) + if (indents.topIsWrap && !indents.topIs(tok!",")) { indents.pop; } diff --git a/tests/allman/argument_chain_indent.d.ref b/tests/allman/argument_chain_indent.d.ref index 80ccb2f..21bf640 100644 --- a/tests/allman/argument_chain_indent.d.ref +++ b/tests/allman/argument_chain_indent.d.ref @@ -8,6 +8,16 @@ class C .map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__); + + g(map && map && map && map && map && map && map && map && map && map && map + && map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __LINE__); + h(map || map || map || map || map || map || map || map || map || map || map + || map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __LINE__); + i(map + map + map + map + map + map + map + map + map + map + map + map + map + + map + map + map + map + map, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __FILE__, __FILE__, __LINE__); } } } diff --git a/tests/allman/argument_chain_keep_breaks.d.ref b/tests/allman/argument_chain_keep_breaks.d.ref index 8c6dd16..2acf1f8 100644 --- a/tests/allman/argument_chain_keep_breaks.d.ref +++ b/tests/allman/argument_chain_keep_breaks.d.ref @@ -10,6 +10,22 @@ class C .to!string, __FILE__, __LINE__); + + g( + map && + map, + __FILE__, + __LINE__); + h( + map || + map, + __FILE__, + __LINE__); + i( + map + + map, + __FILE__, + __LINE__); } } } diff --git a/tests/argument_chain_indent.d b/tests/argument_chain_indent.d index 6fc0f4a..57fd4ed 100644 --- a/tests/argument_chain_indent.d +++ b/tests/argument_chain_indent.d @@ -23,6 +23,38 @@ class C __FILE__, __FILE__, __LINE__); + + g( + map && map && map && map && map && map && map && map && map && map && map && map, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __LINE__); + h( + map || map || map || map || map || map || map || map || map || map || map || map, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __LINE__); + i( + map + map + map + map + map + map + map + map + map + map + map + map + map + map + map + map + map + + map, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __FILE__, + __LINE__); } } } diff --git a/tests/argument_chain_keep_breaks.d b/tests/argument_chain_keep_breaks.d index 8c6dd16..a0c4afe 100644 --- a/tests/argument_chain_keep_breaks.d +++ b/tests/argument_chain_keep_breaks.d @@ -10,6 +10,22 @@ class C .to!string, __FILE__, __LINE__); + + g( + map && + map, + __FILE__, + __LINE__); + h( + map || + map, + __FILE__, + __LINE__); + i( + map + + map, + __FILE__, + __LINE__); } } } diff --git a/tests/knr/argument_chain_indent.d.ref b/tests/knr/argument_chain_indent.d.ref index 5c6b87c..333d711 100644 --- a/tests/knr/argument_chain_indent.d.ref +++ b/tests/knr/argument_chain_indent.d.ref @@ -6,6 +6,16 @@ class C { .map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__); + + g(map && map && map && map && map && map && map && map && map && map && map + && map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __LINE__); + h(map || map || map || map || map || map || map || map || map || map || map + || map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __LINE__); + i(map + map + map + map + map + map + map + map + map + map + map + map + map + + map + map + map + map + map, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __FILE__, __FILE__, __LINE__); } } } diff --git a/tests/knr/argument_chain_keep_breaks.d.ref b/tests/knr/argument_chain_keep_breaks.d.ref index 2d80d31..4d3a419 100644 --- a/tests/knr/argument_chain_keep_breaks.d.ref +++ b/tests/knr/argument_chain_keep_breaks.d.ref @@ -8,6 +8,22 @@ class C { .to!string, __FILE__, __LINE__); + + g( + map && + map, + __FILE__, + __LINE__); + h( + map || + map, + __FILE__, + __LINE__); + i( + map + + map, + __FILE__, + __LINE__); } } } diff --git a/tests/otbs/argument_chain_indent.d.ref b/tests/otbs/argument_chain_indent.d.ref index 47166fa..6a823b1 100644 --- a/tests/otbs/argument_chain_indent.d.ref +++ b/tests/otbs/argument_chain_indent.d.ref @@ -5,6 +5,16 @@ class C { .map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__); + + g(map && map && map && map && map && map && map && map && map && map && map + && map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __LINE__); + h(map || map || map || map || map || map || map || map || map || map || map + || map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __LINE__); + i(map + map + map + map + map + map + map + map + map + map + map + map + map + + map + map + map + map + map, __FILE__, __FILE__, __FILE__, + __FILE__, __FILE__, __FILE__, __FILE__, __LINE__); } } } diff --git a/tests/otbs/argument_chain_keep_breaks.d.ref b/tests/otbs/argument_chain_keep_breaks.d.ref index 7a561d0..b67df88 100644 --- a/tests/otbs/argument_chain_keep_breaks.d.ref +++ b/tests/otbs/argument_chain_keep_breaks.d.ref @@ -7,6 +7,22 @@ class C { .to!string, __FILE__, __LINE__); + + g( + map && + map, + __FILE__, + __LINE__); + h( + map || + map, + __FILE__, + __LINE__); + i( + map + + map, + __FILE__, + __LINE__); } } }