Skip to content

Insert a final newline if needed#300

Merged
DHowett merged 2 commits into
mainfrom
users/lhecker/41-final-newline
May 27, 2025
Merged

Insert a final newline if needed#300
DHowett merged 2 commits into
mainfrom
users/lhecker/41-final-newline

Conversation

@lhecker

@lhecker lhecker commented May 27, 2025

Copy link
Copy Markdown
Member
  • Detects any final newline on open
  • ...otherwise assumes "false" on Windows
  • If there was a final newline, we now insert one automatically
    if the user wrote something at the end of the file

Closes #41

Comment thread src/buffer/mod.rs Outdated
@DHowett DHowett merged commit 09af110 into main May 27, 2025
1 check passed
@DHowett DHowett deleted the users/lhecker/41-final-newline branch May 27, 2025 01:21
@jantari

jantari commented Jun 19, 2025

Copy link
Copy Markdown

I'm curious, what is the story of no final newline on Windows? I thought having the final newline was the universally correct way to write / save a text file on all platforms.

@DHowett

DHowett commented Jun 19, 2025

Copy link
Copy Markdown
Member

@jantari If you want all the terrible terrible details, read #41 - people are very upset about it ;P

@lhecker

lhecker commented Jun 19, 2025

Copy link
Copy Markdown
Member Author

The same applies to the default line endings, which are also CRLF on Windows and LF anywhere else. I personally have set up all my editors to use LF and produce a final newline, but people don't like that.

The upside of this approach is that it appears to work quite well at least on existing files.

@jantari

jantari commented Jun 20, 2025

Copy link
Copy Markdown

Well, for this editor at least (being simple, approachable, built-in), not changing it in existing files is certainly the best choice. No final newline in new files looks to mostly be the opinion of one very upset individual there, but oh well. I realize this PR is not the place to harp on that and a decision has been made. Thanks for the link and comments.

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.

Edit produces documents with no LF/CRLF after the last line

3 participants