obey `end_of_line` setting in all tokens (#550)
Multi-line tokens would be written with `LF`, regardless the `end_of_line` setting. Fixes #228 and also produces end_of_line specified line-endings in strings.
This commit is contained in:
parent
77e2ba4e3d
commit
f81ddeadbd
|
@ -0,0 +1,4 @@
|
||||||
|
tests/issue0228.d text eol=lf
|
||||||
|
tests/allman/issue0228.d.ref text eol=crlf
|
||||||
|
tests/knr/issue0228.d.ref text eol=crlf
|
||||||
|
tests/otbs/issue0228.d.ref text eol=crlf
|
|
@ -1825,6 +1825,8 @@ private:
|
||||||
{
|
{
|
||||||
import std.range:retro;
|
import std.range:retro;
|
||||||
import std.algorithm.searching:countUntil;
|
import std.algorithm.searching:countUntil;
|
||||||
|
import std.algorithm.iteration:joiner;
|
||||||
|
import std.string:lineSplitter;
|
||||||
|
|
||||||
if (current.text is null)
|
if (current.text is null)
|
||||||
{
|
{
|
||||||
|
@ -1834,12 +1836,7 @@ private:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// You know what's awesome? Windows can't handle its own line
|
output.put(current.text.lineSplitter.joiner(eolString));
|
||||||
// endings correctly.
|
|
||||||
version (Windows)
|
|
||||||
output.put(current.text.replace("\r", ""));
|
|
||||||
else
|
|
||||||
output.put(current.text);
|
|
||||||
switch (current.type)
|
switch (current.type)
|
||||||
{
|
{
|
||||||
case tok!"stringLiteral":
|
case tok!"stringLiteral":
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* This test relies on ../.gitattributes to contain these lines:
|
||||||
|
|
||||||
|
tests/issue0228.d text eol=lf
|
||||||
|
tests/allman/issue0228.d.ref text eol=crlf
|
||||||
|
tests/knr/issue0228.d.ref text eol=crlf
|
||||||
|
tests/otbs/issue0228.d.ref text eol=crlf
|
||||||
|
|
||||||
|
*/
|
|
@ -0,0 +1 @@
|
||||||
|
--end_of_line=crlf
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* This test relies on ../.gitattributes to contain these lines:
|
||||||
|
|
||||||
|
tests/issue0228.d text eol=lf
|
||||||
|
tests/allman/issue0228.d.ref text eol=crlf
|
||||||
|
tests/knr/issue0228.d.ref text eol=crlf
|
||||||
|
tests/otbs/issue0228.d.ref text eol=crlf
|
||||||
|
|
||||||
|
*/
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* This test relies on ../.gitattributes to contain these lines:
|
||||||
|
|
||||||
|
tests/issue0228.d text eol=lf
|
||||||
|
tests/allman/issue0228.d.ref text eol=crlf
|
||||||
|
tests/knr/issue0228.d.ref text eol=crlf
|
||||||
|
tests/otbs/issue0228.d.ref text eol=crlf
|
||||||
|
|
||||||
|
*/
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* This test relies on ../.gitattributes to contain these lines:
|
||||||
|
|
||||||
|
tests/issue0228.d text eol=lf
|
||||||
|
tests/allman/issue0228.d.ref text eol=crlf
|
||||||
|
tests/knr/issue0228.d.ref text eol=crlf
|
||||||
|
tests/otbs/issue0228.d.ref text eol=crlf
|
||||||
|
|
||||||
|
*/
|
Loading…
Reference in New Issue