diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index bbc42f1..630d087 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -1398,6 +1398,9 @@ private: void writeToken() { + import std.range:retro; + import std.algorithm.searching:countUntil; + if (current.text is null) { immutable s = str(current.type); @@ -1412,7 +1415,18 @@ private: output.put(current.text.replace("\r", "")); else output.put(current.text); - currentLineLength += current.text.length; + switch (current.type) + { + case tok!"stringLiteral": + case tok!"wstringLiteral": + case tok!"dstringLiteral": + immutable o = current.text.retro().countUntil('\n'); + currentLineLength += o == -1 ? current.text.length : o; + break; + default: + currentLineLength += current.text.length; + break; + } } index++; } diff --git a/tests/allman/multiline_string.d.ref b/tests/allman/multiline_string.d.ref new file mode 100644 index 0000000..48ebf98 --- /dev/null +++ b/tests/allman/multiline_string.d.ref @@ -0,0 +1,12 @@ +unittest +{ + someFunctionCall(` + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + `, paramater); +} diff --git a/tests/multiline_string.d b/tests/multiline_string.d new file mode 100644 index 0000000..fd617fa --- /dev/null +++ b/tests/multiline_string.d @@ -0,0 +1,13 @@ +unittest +{ + someFunctionCall(` + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + `, + paramater); +} diff --git a/tests/otbs/multiline_string.d.ref b/tests/otbs/multiline_string.d.ref new file mode 100644 index 0000000..1aba27c --- /dev/null +++ b/tests/otbs/multiline_string.d.ref @@ -0,0 +1,11 @@ +unittest { + someFunctionCall(` + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + multi-line string + `, paramater); +}