Skip to content
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

fix: keep the newline char if file ends with that #20

Merged
merged 3 commits into from
Dec 22, 2024

Conversation

s12f
Copy link
Contributor

@s12f s12f commented Dec 19, 2024

I found if the input file ends with the '\n', tlauc will delete the newline char, I think tlauc should keep the file same as possible, files ends with the newline char are quite normal(as https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline said, the Posix standard defines a line should end with a newline char, and some editors(e.g. neovim) will automatically put a newline char in the end).

@ahelwer
Copy link
Contributor

ahelwer commented Dec 19, 2024

Thanks! Could you add some tests for this? In particular, I would like to see the behavior if empty input is provided.

@s12f
Copy link
Contributor Author

s12f commented Dec 20, 2024

@ahelwer added some tests, in the cases that input is empty or empty ends with a newline, the replace_symbols will panic in origin codes, so I add https://github.com/tlaplus-community/tlauc/pull/20/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R457-R459

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@s12f s12f requested a review from ahelwer December 22, 2024 04:55
@ahelwer
Copy link
Contributor

ahelwer commented Dec 22, 2024

Great changes, thanks!

@ahelwer ahelwer merged commit 0e62498 into tlaplus-community:main Dec 22, 2024
3 checks passed
@s12f s12f deleted the keep_newline branch January 4, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants