-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly format files with dos line endings #81
Conversation
printer/src/algorithm.rs
Outdated
} | ||
} | ||
|
||
pub fn set_dos(&mut self, value: bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could pass this to the constructor of Printer
instead, no need for a setter in that case.
(I don't think you would ever switch to a different line ending style halfway formatting, so it does not have to be mutable)
hey, thanks for your contribution! I am not really a fan of platform specific line endings. Files are transferred from one platform to the other, etc. And I believe on the reading side every editor would be able to read LF line endings? I haven't use windows in ages, but I think you could configure git to automatically convert line endings to LF. Anyhow, it is still nice to support this. Code looks good to me, only have some very minor suggestions (mostly naming), well done 👍 |
I think most people will be fine with having the formatter automatically detect line endings, but if you feel like it, you could also add a configuration option https://github.com/bram209/leptosfmt/blob/main/formatter/src/formatter/mod.rs#L38 This could have the following variants: Where val crlf_line_endings = cfg!(windows) But if you want to leave it at what you currently have, that is perfectly fine as well : ) |
CRLF is default on windows. But git will replace CRLF as LF when a commit is done, but files will stay as CRLF for editing locally. I understand this is not good but that's windows 🤷 . I will try to move away from CRLF
I would like to do this later as I don't conditional compilation stuff yet. Will definitely give it a go later |
d661320
to
e4529e6
Compare
* Correctly format files with dos line endings * Refactor and naming improvements * Avoid panic on empty file [skip ci] Update CHANGELOG.md [skip ci] Update CHANGELOG.md
* Correctly format files with dos line endings * Refactor and naming improvements * Avoid panic on empty file [skip ci] Update CHANGELOG.md [skip ci] Update CHANGELOG.md
Closes #80
I did this the simplest way, but it may not be the right way. Please suggest if something can be improved or changed