Skip to content

When auto-fixing, added line-ending should match line-ending of file being edited #665

Open

Description

@somewhatabstract

When auto-fixing, we use the \n character as a line-ending, but on Windows, the line-ending is more likely to be \r\n. We could use os.EOL but this may not match the file that we are fixing, so we should detect the line ending during parsing and then use that.

Activity

  1. somewhatabstract commented on Mar 8, 2025

    @somewhatabstract
    OwnerAuthor

    In order to implement this, we need to change how we parse files. Currently, we use readline, which handles line endings for us, but doesn't give us a way to determine what they are. Instead, we likely need to implement our own readline so that we can look at the line-endings ourselves. There may be a third-party library that will help with this.

    As the issue says, we could do something that defers line-endings to the local OS (os.EOL), but that doesn't solve the problem since we can be processing files with different line endings to the system default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions