diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index c4d2e68..acd4724 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -642,6 +642,9 @@ private: } else if (p == tok!"[" && config.dfmt_keep_line_breaks == OptionalBoolean.t) { + if (peekBack2Is(tok!"(")) { + indents.pop(); + } IndentStack.Details detail; detail.wrap = false; diff --git a/tests/allman/keep_break_in_array_arg.d.ref b/tests/allman/keep_break_in_array_arg.d.ref new file mode 100644 index 0000000..88bc23f --- /dev/null +++ b/tests/allman/keep_break_in_array_arg.d.ref @@ -0,0 +1,6 @@ +unittest +{ + f([ + x + ]); +} diff --git a/tests/keep_break_in_array_chain.d.args b/tests/keep_break_in_array_arg.args similarity index 100% rename from tests/keep_break_in_array_chain.d.args rename to tests/keep_break_in_array_arg.args diff --git a/tests/keep_break_in_array_arg.d b/tests/keep_break_in_array_arg.d new file mode 100644 index 0000000..88bc23f --- /dev/null +++ b/tests/keep_break_in_array_arg.d @@ -0,0 +1,6 @@ +unittest +{ + f([ + x + ]); +} diff --git a/tests/keep_break_in_array_chain.args b/tests/keep_break_in_array_chain.args new file mode 100644 index 0000000..7e7e52d --- /dev/null +++ b/tests/keep_break_in_array_chain.args @@ -0,0 +1 @@ +--keep_line_breaks=true diff --git a/tests/knr/keep_break_in_array_arg.d.ref b/tests/knr/keep_break_in_array_arg.d.ref new file mode 100644 index 0000000..5f56bb7 --- /dev/null +++ b/tests/knr/keep_break_in_array_arg.d.ref @@ -0,0 +1,5 @@ +unittest { + f([ + x + ]); +} diff --git a/tests/otbs/keep_break_in_array_arg.d.ref b/tests/otbs/keep_break_in_array_arg.d.ref new file mode 100644 index 0000000..5f56bb7 --- /dev/null +++ b/tests/otbs/keep_break_in_array_arg.d.ref @@ -0,0 +1,5 @@ +unittest { + f([ + x + ]); +}