obey `end_of_line` setting in all tokens ()

Multi-line tokens would be written with `LF`, regardless the `end_of_line` setting.

Fixes  and also produces end_of_line specified line-endings in strings.
This commit is contained in:
Bastiaan Veelo 2022-05-25 13:21:07 +02:00 committed by GitHub
parent 77e2ba4e3d
commit f81ddeadbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 6 deletions

4
.gitattributes vendored Normal file
View File

@ -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

View File

@ -1825,6 +1825,8 @@ private:
{
import std.range:retro;
import std.algorithm.searching:countUntil;
import std.algorithm.iteration:joiner;
import std.string:lineSplitter;
if (current.text is null)
{
@ -1834,12 +1836,7 @@ private:
}
else
{
// You know what's awesome? Windows can't handle its own line
// endings correctly.
version (Windows)
output.put(current.text.replace("\r", ""));
else
output.put(current.text);
output.put(current.text.lineSplitter.joiner(eolString));
switch (current.type)
{
case tok!"stringLiteral":

View File

@ -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
*/

1
tests/issue0228.args Normal file
View File

@ -0,0 +1 @@
--end_of_line=crlf

8
tests/issue0228.d Normal file
View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/