diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 5184092..a4a37c5 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -726,6 +726,8 @@ private: indents.pop(); if (indents.topIs(tok!"(")) indents.pop(); + if (indents.topIs(tok!".")) + indents.pop(); if (onNextLine) { @@ -1440,7 +1442,8 @@ private: if (ufcsWrap || linebreakHints.canFind(index) || onNextLine || (linebreakHints.length == 0 && currentLineLength + nextTokenLength() > config.max_line_length)) { - pushWrapIndent(); + if (!indents.topIs(tok!".")) + indents.push(tok!"."); if (!peekBackIs(tok!"comment")) newline(); if (ufcsWrap || onNextLine) diff --git a/tests/allman/issue0494.d.ref b/tests/allman/issue0494.d.ref new file mode 100644 index 0000000..282567a --- /dev/null +++ b/tests/allman/issue0494.d.ref @@ -0,0 +1,29 @@ +void main() +{ + const a1 = [ + builder.rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder.rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder.rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() +{ + afdsafds.asdf.flub; +} diff --git a/tests/allman/issue0494_keep_line_break.d.ref b/tests/allman/issue0494_keep_line_break.d.ref new file mode 100644 index 0000000..5e8d7a1 --- /dev/null +++ b/tests/allman/issue0494_keep_line_break.d.ref @@ -0,0 +1,34 @@ +void main() +{ + const a1 = [ + builder + .rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() +{ + afdsafds + .asdf + .flub; +} diff --git a/tests/issue0494.d b/tests/issue0494.d new file mode 100644 index 0000000..5e3f6d0 --- /dev/null +++ b/tests/issue0494.d @@ -0,0 +1,33 @@ +void main() +{ + const a1 = [ + builder + .rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() { + afdsafds + .asdf + .flub; +} diff --git a/tests/issue0494_keep_line_break.args b/tests/issue0494_keep_line_break.args new file mode 100644 index 0000000..7e7e52d --- /dev/null +++ b/tests/issue0494_keep_line_break.args @@ -0,0 +1 @@ +--keep_line_breaks=true diff --git a/tests/issue0494_keep_line_break.d b/tests/issue0494_keep_line_break.d new file mode 100644 index 0000000..5e3f6d0 --- /dev/null +++ b/tests/issue0494_keep_line_break.d @@ -0,0 +1,33 @@ +void main() +{ + const a1 = [ + builder + .rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() { + afdsafds + .asdf + .flub; +} diff --git a/tests/knr/issue0494.d.ref b/tests/knr/issue0494.d.ref new file mode 100644 index 0000000..282567a --- /dev/null +++ b/tests/knr/issue0494.d.ref @@ -0,0 +1,29 @@ +void main() +{ + const a1 = [ + builder.rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder.rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder.rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() +{ + afdsafds.asdf.flub; +} diff --git a/tests/knr/issue0494_keep_line_break.d.ref b/tests/knr/issue0494_keep_line_break.d.ref new file mode 100644 index 0000000..5e8d7a1 --- /dev/null +++ b/tests/knr/issue0494_keep_line_break.d.ref @@ -0,0 +1,34 @@ +void main() +{ + const a1 = [ + builder + .rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() +{ + afdsafds + .asdf + .flub; +} diff --git a/tests/otbs/issue0494.d.ref b/tests/otbs/issue0494.d.ref new file mode 100644 index 0000000..cb0c477 --- /dev/null +++ b/tests/otbs/issue0494.d.ref @@ -0,0 +1,27 @@ +void main() { + const a1 = [ + builder.rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder.rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder.rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() { + afdsafds.asdf.flub; +} diff --git a/tests/otbs/issue0494_keep_line_break.d.ref b/tests/otbs/issue0494_keep_line_break.d.ref new file mode 100644 index 0000000..34d6306 --- /dev/null +++ b/tests/otbs/issue0494_keep_line_break.d.ref @@ -0,0 +1,32 @@ +void main() { + const a1 = [ + builder + .rebuild!((x, y, z) => x + y + z) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + const a2 = [ + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + builder + .rebuild!(x => x) + .rebuild!(x => x) + .rebuild!(x => x), + ]; + + foo([ + line1, + value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c) + .propertyCallBlaBlaBla(a, b, c).value, + ]); +} + +void foo() { + afdsafds + .asdf + .flub; +}