Plugin-php: Windows-style line endings confuse comments

Created on 29 Mar 2018  路  5Comments  路  Source: prettier/plugin-php

I know this sounds crazy, but here's my edge case: In a file with windows-style line endings, which is also using tabs for indentation, the comments seem to be indented wrong.

Example input:

class Foo {
    /**
     * Comment indented with tabs in file with utf-8[dos]
     */
    private $foo;
}

Output:

class Foo
{
    /**
         * Comment indented with tabs in file with utf-8[dos]
         */
    private $foo;
}

I didn't manage to reproduce this in a test, it only breaks when i run prettier directly through the CLI 馃槙

bug

All 5 comments

/cc @vjeux @azz how we can tests windows, looks like tests remove windows lines

@evilebottnawi prettier shouldn't remove windows line ending. It has special logic to detect the line type and use it everywhere:

https://github.com/prettier/prettier/blob/13103101ebd6bc563fb6cc765186244b90d8300e/index.js#L20-L26
https://github.com/prettier/prettier/blob/master/src/doc/doc-printer.js#L201

Just stumbled over this line, which is probably the reason that i wasn't able to reproduce the issue in a test:

https://github.com/prettier/plugin-php/blob/964d851c91e34cde1d1650635aafb21bd1b612cd/tests_config/run_spec.js#L33

@czosel I haven't been able to reproduce this... can you confirm if this is still happening? Also adding a test here https://github.com/prettier/plugin-php/pull/406

@mgrip Looks like this has been fixed somewhere along the way (probably when we refactored comment printing) 馃憤

Was this page helpful?
0 / 5 - 0 ratings