Skip to content

Garbled contents when reloading file with DOS line endings #3303

@scurest

Description

@scurest

Description of the problem

When reloading a DOS-mode file (CRLF line endings) that has changed on disk, the file contents are garbled.

Steps to reproduce

To help repro, here's a Python script that writes a random test.txt with DOS line endings.

# a.py
import random, sys
random.seed(sys.argv[1])
with open('test.txt', 'w') as f:
    for _ in range(6):
        f.write(str(random.randint(0,999)))
        f.write("\r\n")

I run python a.py 1 and then open the test file with micro test.txt.

Then I run python a.py 2 to change the file. Micro prompts me to reload: The file on disk has changed. Reload file? (y,n,esc). I hit y. I get

Note that this is not a display issue, the actual contents are garbled. You can keep repeating this, python a.py 3 and so on.

Note that this does NOT happen if a.py is changed to write \n line endings AND if micro initially opened the file in unix mode.

Specifications

Commit hash: 68d88b5
OS: Arch Linux
Terminal: xterm 390-2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions