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 final line ending #635

Merged
merged 3 commits into from
Jun 5, 2024
Merged

Fix final line ending #635

merged 3 commits into from
Jun 5, 2024

Conversation

vinc
Copy link
Owner

@vinc vinc commented Jun 4, 2024

The previous PR #632 introduced an issue on empty files, because "".split('\n') would produce [""] whereas "".lines() would produce [] resulting in a panic on the editor and the viewer.

We can add back an empty line if a file contains no lines, but it's also the occasion to deal with something that could be improved: in POSIX the last line of a file must end with a newline, and this make sense so MOROS follows this rule. But the editor would explicitely show an empty line at the end of every file to save this trailing newline chars. And when editing a file you'd have to remember to always leave an empty line at the end.

In general it seems better to make that final newline implicit and avoid displaying an empty line at the end of every files.

The only caveat is that on some occasions we might want to produce a file without a trailing newline. This will now be impossible, we'll see if it's needed in the future and revisit that decision then. It could just be an option in the editor.

@vinc
Copy link
Owner Author

vinc commented Jun 4, 2024

Interesting read: https://stackoverflow.com/a/729795

@vinc vinc marked this pull request as ready for review June 5, 2024 16:10
@vinc vinc merged commit 8a21f2e into trunk Jun 5, 2024
1 check passed
@vinc vinc deleted the fix/lines branch June 5, 2024 16:10
@vinc vinc mentioned this pull request Jun 18, 2024
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.

1 participant