diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index ae3f798..4017870 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -1715,7 +1715,14 @@ private: } else if (currentIs(tok!"case") || currentIs(tok!"default")) { - if (peekBackIs(tok!"}", true) || peekBackIs(tok!";", true)) + + if (peekBackIs(tok!"}", true) || peekBackIs(tok!";", true) + /** + * The following code is valid and should be indented flatly + * case A: + * case B: + */ + || peekBackIs(tok!":", true)) { indents.popTempIndents(); if (indents.topIs(tok!"case")) diff --git a/tests/allman/issue0483.d.ref b/tests/allman/issue0483.d.ref new file mode 100644 index 0000000..1d77e68 --- /dev/null +++ b/tests/allman/issue0483.d.ref @@ -0,0 +1,15 @@ +module tests.issue0483; + +void main() +{ + switch (0) + { + case 1: + case 2: + label: + case 3: + break; + default: + break; + } +} diff --git a/tests/issue0483.args b/tests/issue0483.args new file mode 100644 index 0000000..91e2439 --- /dev/null +++ b/tests/issue0483.args @@ -0,0 +1 @@ +--align_switch_statements=false diff --git a/tests/issue0483.d b/tests/issue0483.d new file mode 100644 index 0000000..1d77e68 --- /dev/null +++ b/tests/issue0483.d @@ -0,0 +1,15 @@ +module tests.issue0483; + +void main() +{ + switch (0) + { + case 1: + case 2: + label: + case 3: + break; + default: + break; + } +} diff --git a/tests/otbs/issue0483.d.ref b/tests/otbs/issue0483.d.ref new file mode 100644 index 0000000..b23c692 --- /dev/null +++ b/tests/otbs/issue0483.d.ref @@ -0,0 +1,13 @@ +module tests.issue0483; + +void main() { + switch (0) { + case 1: + case 2: + label: + case 3: + break; + default: + break; + } +}