diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 6f9b7cc..c922c5f 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -9,8 +9,9 @@ module dfmt.formatter; import dparse.lexer; import dparse.parser; import dparse.rollback_allocator; -import dfmt.config; import dfmt.ast_info; +import dfmt.config; +import dfmt.editorconfig : OptionalBoolean; import dfmt.indentation; import dfmt.tokens; import dfmt.wrapping; @@ -477,7 +478,8 @@ private: immutable j = justAddedExtraNewline; if (currIsSlashSlash) { - newline(); + if (config.dfmt_keep_line_breaks != OptionalBoolean.t) + newline(); justAddedExtraNewline = j; } else if (hasCurrent) @@ -584,8 +586,6 @@ private: } do { - import dfmt.editorconfig : OptionalBoolean; - immutable p = current.type; regenLineBreakHintsIfNecessary(index); writeToken(); diff --git a/tests/allman/issue0490.d.ref b/tests/allman/issue0490.d.ref new file mode 100644 index 0000000..0a25298 --- /dev/null +++ b/tests/allman/issue0490.d.ref @@ -0,0 +1,6 @@ +void foo() +{ + afdsafds + .asdf // blah + .flub; +} diff --git a/tests/issue0490.args b/tests/issue0490.args new file mode 100644 index 0000000..7e7e52d --- /dev/null +++ b/tests/issue0490.args @@ -0,0 +1 @@ +--keep_line_breaks=true diff --git a/tests/issue0490.d b/tests/issue0490.d new file mode 100644 index 0000000..0a25298 --- /dev/null +++ b/tests/issue0490.d @@ -0,0 +1,6 @@ +void foo() +{ + afdsafds + .asdf // blah + .flub; +} diff --git a/tests/otbs/issue0490.d.ref b/tests/otbs/issue0490.d.ref new file mode 100644 index 0000000..7332368 --- /dev/null +++ b/tests/otbs/issue0490.d.ref @@ -0,0 +1,5 @@ +void foo() { + afdsafds + .asdf // blah + .flub; +}