diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 2078a7c..f649ed3 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -720,6 +720,12 @@ private: void revertParenIndentation() { + import std.algorithm.searching : canFind, until; + + if (tokens[index .. $].until!(tok => tok.line != current.line).canFind!(x => x.type == tok!"]")) + { + return; + } if (parenDepthOnLine) { foreach (i; 0 .. parenDepthOnLine) diff --git a/tests/allman/keep_break_in_array_arg.d.ref b/tests/allman/keep_break_in_array_arg.d.ref index 88bc23f..0c3de1c 100644 --- a/tests/allman/keep_break_in_array_arg.d.ref +++ b/tests/allman/keep_break_in_array_arg.d.ref @@ -4,3 +4,8 @@ unittest x ]); } + +void f(T[] x, + const U y) +{ +} diff --git a/tests/keep_break_in_array_arg.d b/tests/keep_break_in_array_arg.d index 88bc23f..aa4cd4c 100644 --- a/tests/keep_break_in_array_arg.d +++ b/tests/keep_break_in_array_arg.d @@ -4,3 +4,8 @@ unittest x ]); } + +void f(T[] x, + const U y) +{ +} diff --git a/tests/knr/keep_break_in_array_arg.d.ref b/tests/knr/keep_break_in_array_arg.d.ref index 5f56bb7..4025544 100644 --- a/tests/knr/keep_break_in_array_arg.d.ref +++ b/tests/knr/keep_break_in_array_arg.d.ref @@ -3,3 +3,8 @@ unittest { x ]); } + +void f(T[] x, + const U y) +{ +} diff --git a/tests/otbs/keep_break_in_array_arg.d.ref b/tests/otbs/keep_break_in_array_arg.d.ref index 5f56bb7..7da40ee 100644 --- a/tests/otbs/keep_break_in_array_arg.d.ref +++ b/tests/otbs/keep_break_in_array_arg.d.ref @@ -3,3 +3,7 @@ unittest { x ]); } + +void f(T[] x, + const U y) { +}