From 42bb512d935de037a459e86d53e03edb2430add0 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 8 Jun 2022 11:06:43 +0200 Subject: [PATCH] Revert nested indentation --- src/dfmt/formatter.d | 5 ++++- tests/allman/foreach_array.d.ref | 15 +++++++++++++++ tests/foreach_array.d | 15 +++++++++++++++ tests/knr/foreach_array.d.ref | 13 +++++++++++++ tests/otbs/foreach_array.d.ref | 13 +++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 35bd4da..5184092 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -703,7 +703,10 @@ private: { if (parenDepthOnLine) { - indents.pop(); + foreach (i; 0 .. parenDepthOnLine) + { + indents.pop(); + } indents.popTempIndents(); } parenDepthOnLine = 0; diff --git a/tests/allman/foreach_array.d.ref b/tests/allman/foreach_array.d.ref index 7f37fff..e714129 100644 --- a/tests/allman/foreach_array.d.ref +++ b/tests/allman/foreach_array.d.ref @@ -36,4 +36,19 @@ void f() send(TextDocument.publishDiagnostics, new PublishDiagnosticsParams(uri, [ ])); } + + foreach (x; map([ + 1, + 2, + 3, + ])) + { + } + foreach (x; foo!(map!([ + 1, + 2, + 3, + ]))) + { + } } diff --git a/tests/foreach_array.d b/tests/foreach_array.d index 45de9a6..8e8ea0f 100644 --- a/tests/foreach_array.d +++ b/tests/foreach_array.d @@ -35,4 +35,19 @@ void f() { send(TextDocument.publishDiagnostics, new PublishDiagnosticsParams(uri, [])); } + + foreach (x; map([ + 1, + 2, + 3, + ])) + { + } + foreach (x; foo!(map!([ + 1, + 2, + 3, + ]))) + { + } } diff --git a/tests/knr/foreach_array.d.ref b/tests/knr/foreach_array.d.ref index 9eb0611..f0d447e 100644 --- a/tests/knr/foreach_array.d.ref +++ b/tests/knr/foreach_array.d.ref @@ -31,4 +31,17 @@ void f() send(TextDocument.publishDiagnostics, new PublishDiagnosticsParams(uri, [ ])); } + + foreach (x; map([ + 1, + 2, + 3, + ])) { + } + foreach (x; foo!(map!([ + 1, + 2, + 3, + ]))) { + } } diff --git a/tests/otbs/foreach_array.d.ref b/tests/otbs/foreach_array.d.ref index b15f2f7..b505616 100644 --- a/tests/otbs/foreach_array.d.ref +++ b/tests/otbs/foreach_array.d.ref @@ -30,4 +30,17 @@ void f() { send(TextDocument.publishDiagnostics, new PublishDiagnosticsParams(uri, [ ])); } + + foreach (x; map([ + 1, + 2, + 3, + ])) { + } + foreach (x; foo!(map!([ + 1, + 2, + 3, + ]))) { + } }