diff --git a/appveyor.yml b/appveyor.yml index 8c31ccf..0c1a59b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,18 +19,18 @@ environment: - DC: dmd DVersion: stable arch: x86 - - DC: ldc - DVersion: beta - arch: x86 - - DC: ldc - DVersion: beta - arch: x64 - - DC: ldc - DVersion: stable - arch: x86 - - DC: ldc - DVersion: stable - arch: x64 +# - DC: ldc +# DVersion: beta +# arch: x86 +# - DC: ldc +# DVersion: beta +# arch: x64 +# - DC: ldc +# DVersion: stable +# arch: x86 +# - DC: ldc +# DVersion: stable +# arch: x64 skip_tags: false branches: diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 14c56d4..760b4f7 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -841,7 +841,8 @@ private: justAddedExtraNewline = true; } if (config.dfmt_brace_style == BraceStyle.otbs - && peekIs(tok!"else") && !indents.topAre(tok!"static", tok!"if")) + && peekIs(tok!"else") && !indents.topAre(tok!"static", tok!"if") + && !indents.topIs(tok!"foreach")) { write(" "); index++; @@ -852,7 +853,7 @@ private: && !peekIs(tok!";") && !peekIs(tok!"{")) { index++; - if (indents.topIs(tok!"static")) + if (indents.topIsOneOf(tok!"static", tok!"foreach")) indents.pop(); newline(); } diff --git a/src/dfmt/indentation.d b/src/dfmt/indentation.d index f065945..f992ec3 100644 --- a/src/dfmt/indentation.d +++ b/src/dfmt/indentation.d @@ -159,14 +159,17 @@ struct IndentStack return cast(int) index; } - /+void dump() + /** + * Dumps the current state of the indentation stack to `stderr`. Used for debugging. + */ + void dump() { import std.stdio : stderr; import dparse.lexer : str; import std.algorithm.iteration : map; stderr.writefln("\033[31m%(%s %)\033[0m", arr[0 .. index].map!(a => str(a))); - }+/ + } private: diff --git a/tests/allman/issue0314.d.ref b/tests/allman/issue0314.d.ref new file mode 100644 index 0000000..94808e1 --- /dev/null +++ b/tests/allman/issue0314.d.ref @@ -0,0 +1,11 @@ +void main() +{ + auto d = { + if (a) + foreach (b; c) + { + } + else + e(); + }; +} diff --git a/tests/issue0314.d b/tests/issue0314.d new file mode 100644 index 0000000..5b4792c --- /dev/null +++ b/tests/issue0314.d @@ -0,0 +1,9 @@ +void main() +{ + auto d = { + if (a) + foreach (b; c) { } + else + e(); + }; +} diff --git a/tests/otbs/issue0314.d.ref b/tests/otbs/issue0314.d.ref new file mode 100644 index 0000000..2f2427d --- /dev/null +++ b/tests/otbs/issue0314.d.ref @@ -0,0 +1,9 @@ +void main() { + auto d = { + if (a) + foreach (b; c) { + } + else + e(); + }; +}