micro-editor / micro-editor/micro
Garbled contents when reloading file with DOS line endings
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
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: 68d88b57
OS: Arch Linux
Terminal: xterm 390-2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided a.py script to create test.txt, open it in micro, and regenerate it with a different seed. Trace the reload behavior triggered by the file-on-disk prompt; done means repeatedly reloading the CRLF file preserves its actual contents without garbling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100