DioxusLabs / DioxusLabs/dioxus

`dx fmt` inserts Unix newlines into Windows format files

Open
#4,682 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Problem**

When coding on Windows, files usually have the `\r\n` line endings. (Madness, I know!). Running `dx fmt` on either a single file or a group of files, replaces line endings with `\n` (Unix style) only.

If `dx fmt` is run without the `--all-code` flag, this results in mixed line endings - the `rsx!` blocks have `\n` whereas the rest of the file will continue to have `\r\n`.

When run with `--all-code` the entire file switches to `\n`.

Either way Git madness results.

I'm genuinely surprised this doesn't seem to have been reported before! I searched all issues with the word "fmt" in, so I apologise if I missed it.

**Steps To Reproduce**

Steps to reproduce the behavior:

- Create a new Rust file with an rsx block
- Run `dx fmt` on the file.
- Line endings are changed

**Expected behavior**

Line endings respect the existing file conventions, or failing that then the user should be able to specify the desired line endings.

**Screenshots**

n/a

**Environment:**

- Dioxus version: `dx --version > dioxus 0.6.3 (fc1f1c2)`
- Rust version: 1.89 stable
- OS info: Windows (normal Windows, not WSL)
- App platform: n/a

**Questionnaire**

- [x] I'm interested in fixing this myself but don't know where to start.
- [ ] I would like to fix and I have a solution.
- [ ] I don't have time to fix this right now, but maybe later.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.