diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 696b4f8..f8883da 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -1694,8 +1694,8 @@ private: assert(l2 != -1, "Recent '{' is not found despite being in struct initializer"); indentLevel = l2 + 1; } - else if (config.dfmt_compact_labeled_statements == OptionalBoolean.f - || !isBlockHeader(2) || peek2Is(tok!"if")) + else if ((config.dfmt_compact_labeled_statements == OptionalBoolean.f + || !isBlockHeader(2) || peek2Is(tok!"if")) && !indents.topIs(tok!"]")) { immutable l2 = indents.indentToMostRecent(tok!"{"); indentLevel = l2 != -1 ? l2 : indents.indentLevel - 1; diff --git a/tests/allman/assoc_key_indent.d.ref b/tests/allman/assoc_key_indent.d.ref new file mode 100644 index 0000000..a357a35 --- /dev/null +++ b/tests/allman/assoc_key_indent.d.ref @@ -0,0 +1,8 @@ +void main() +{ + string key; + + int[string] var = [ + key: 5 + ]; +} diff --git a/tests/assoc_key_indent.args b/tests/assoc_key_indent.args new file mode 100644 index 0000000..7e7e52d --- /dev/null +++ b/tests/assoc_key_indent.args @@ -0,0 +1 @@ +--keep_line_breaks=true diff --git a/tests/assoc_key_indent.d b/tests/assoc_key_indent.d new file mode 100644 index 0000000..a357a35 --- /dev/null +++ b/tests/assoc_key_indent.d @@ -0,0 +1,8 @@ +void main() +{ + string key; + + int[string] var = [ + key: 5 + ]; +} diff --git a/tests/otbs/assoc_key_indent.d.ref b/tests/otbs/assoc_key_indent.d.ref new file mode 100644 index 0000000..814c7cd --- /dev/null +++ b/tests/otbs/assoc_key_indent.d.ref @@ -0,0 +1,7 @@ +void main() { + string key; + + int[string] var = [ + key: 5 + ]; +}