-
Notifications
You must be signed in to change notification settings - Fork 60
Setting "Ensuring Single Trailing Newline" is broken - the trailing newline is misleadlingly shown in the editor as advertised, but not actually saved in the file on disk #144
Comments
As it appears, all major Linux editors (gedit / vim / ..) actually don't show the last line break ("\n" / ascii 0x0A) at the end because apparently POSIX says they shouldn't. Therefore, this seems to be composed of two bugs:
|
No updates. I work on Windows, but almost everyone else on the Atom team uses macOS. /cc @ungb for reproduction. |
Just to make the ticket more clear, since I am throwing expectations of visible newlines and actual "\n" a bit willy nilly together: What "Ensuring Single Trailing Newline" seems to do right now is:
At this point I am not even sure what it is supposed to do, but I suggest it should be some sort of coherent choice of visible new lines on all platforms, e.g. 1 consistently visible empty line at the end of the file on all platforms. |
Any updates here? I won't be able to use Atom based on this issue alone. |
@jmcriffey you can just disable the whitespace plugin which is what I did |
Yea it is pretty annoying though since whitespace is enabled per default, so if you work on a bigger project with contributors all of them will mess with your project's whitespace too even if you disabled it for yourself. It would be a lot better if this could be finally fixed. |
@ungb That GIF appears to show the correct behavior: after saving the file in Atom, it ends with a single newline. @Jonast I can't reproduce any problem with this. Can you enable the Whitespace package, save a small file in Atom, and show me the contents of the file as reported by For example, if you create a file containing just the word
Note that Atom renders the single empty line at the end of the file, unlike Vim. This is intentional. In Atom, you have the freedom to disable the Whitespace package and you will then be able to save files without trailing newlines. Then they will appear like this:
Because we support the ability to not have a trailing newline, it would not make sense for us to hide the trailing newline, because then you wouldn't be able to tell visually if there was a newline there or not. This is why we show it. Anyway, if you save the file in Atom with the Whitespace package enabled, you should see this in your terminal:
Is that not what you are seeing? |
Could you give me a link to the paragraph in the POSIX standard that talks about these semantics? Also, if this rendering difference is all that you're talking about, then this issue is an exact duplicate of atom/atom#7787, and has nothing to do with the white space package. |
I'm actually going to go ahead and close this out. The way you originally reported the issue, it made it seem like the file was being saved to disk without a trailing newline, but it sounds like you're actually just talking about the rendering issue we mentioned above. If you are actually seeing some problem with the on-disk contents of the file's we're saving, we can reopen. |
The issue IS NOT saved with a trailing newline, as proven by your own hex dump. Please reopen. The only reason it LOOKS like it has a trailing newline is because of a render bug. |
No. The hex dump I reported shows that the file is being saved correctly. It ends with a |
Here are the sources: Relevant POSIX section: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 (please note this implies that characters + http://c0x.coding-guidelines.com/5.1.1.2.html#123 (C standard interpretation which is more concrete and followed by all editors - which basically says Again, this means ending with a |
Basically IMHO you should completely forget about the meaning of Instead, whitespace behavior should be based on actually visible new lines (unrelated to TL;DR: make up your mind about what is actually supposed to be the visible end result, and stop defining this over detailed new line character semantics |
The name of the setting is 'Ensuring Single Trailing Newline'. This name is 100% correct. 'Newline' is a generic term that means a character sequence that represents a line ending. On posix platforms, the character sequence is If you would like to further discuss whether or not we should show the final line number, please comment on atom/atom#7787. |
I think as you describe it, the setting would be useless. Consider the following:
This makes no sense at all. Also, IMHO atom/whitespace is most useful to the users to ensure a consistent display since whitespace is mostly about unified visual consistence and styling, that is something a style checker would complain about. Therefore, a consistent visible amount of newlines is IMHO way more relevant than what happens on a hex dump level. A useful setting would therefore be "Ensure Single Trailing Visible New Line". (Edit: or alternatively considering "Newline" as a visual element and not as the hex dump level new line character Why again are you so absolutely dead-set on hidden whitespace semantics nobody actually sees, and nobody cares about? The fact that Atom has this unintentional display difference because this was missed by so many people should already show that this is a technical underlying detail that has no place in an options dialog, and which no regular user should be concerned about. Again just my humble opinion, but I think your approach here is nitpicky in a way that absolutely hurts the user experience and isn't actually useful. (beyond argueing "but the setting is already named in such a nitpicky way that this interpretation is technically correct" - it might be, but does that help anyone in practice?) Sorry for ranting a bit, I am just trying to illustrate in sufficient detail why I think your position on this should change. I will also refrain from commenting here further since I don't think I can add more. Just please take some time to think about this and whether the current behavior is really useful, and what would be most useful for the users to have.. |
No, I don't think it will show a different number of lines. Converting a file from CRLF line endings to LF line endings will not affect the line count that Atom displays. If you really are seeing this, please record a GIF and open a separate issue for it, as that would be a bug. |
@maxbrunsfeld it does: Here the concrete demonstration of the three bug steps above:
As you can see, atom/whitespace changed this file. That is also the entire point of my rant. And that's also why I think having a setting "append a newline character" (current implementation) is useless to have - what people want is "append a visual new line" (what I am suggesting with this ticket, which requires |
Ok, again, this is exactly the expected behavior. It has nothing to do with whether you're using CRLF line endings or LF line endings. The whitespace package ensures that the file ends with A Single Trailing Newline. Not two trailing newlines; a single trailing newline. You explicitly created a file with two trailing newlines in gedit. Then, when you saved the file in Atom, Atom removed the second trailing newline.
No, I don't think that is what most people want. That is not the built-in behavior of most editors.
|
I really do understand why you care about the line number rendering issue (atom/atom#7787), and I understand that that issue has been ignored. But I really do not think there is any problem with how Atom is saving, loading, or editing these files, and I think the names of our settings are accurate. If you have more UX thoughts on this to share, please do so on that other issue. |
Well but doesn't it add an extra visible |
The setting works exactly the same way on Windows. The setting only ensures that the POSIX standard is followed and is on by default. We do render the line and that is another issue atom/atom#7787 |
@Ben3eeE so on windows, no trailing |
You're confusing the issue by talking about what is "visible", because this differs based on the editor. This setting just ensures an EOF newline sequence. In Atom, this is currently displayed as an "empty line" – in other editors (vim, etc.), it's not. |
The setting does:
So on Windows it would work exactly the same way as on Linux except it would ensure that the last line ends with If you disable this setting then you can save files that don't follow the POSIX standard. I believe other editors also have a setting for this. We do render the line, which might be confusing. |
Atom will detect the line ending that a file is using and adopt that line ending, regardless of your platform. The only time that the platform makes a difference is when you're creating a new file. In that case, Atom will use your platform's line ending. |
Well but in that case it will actually be visually inconsistent between Windows (visible empty line at the end) and Linux (no visible empty line at the end) once atom/atom#7787 is going to be fixed, no?
It doesn't differ based on editor, just based on platform. (unless the editor is broken, which most others than Atom aren't purely regarding this issue)
That is exactly my point. It won't once atom/atom#7787 is fixed based on what the user can see. Of course if you hex dump dive into this it will be a comparable result, but is this relevant to the user? Also it's currently already inconsistent (visually) if you open it with any other linux editor than Atom (no visible empty line at end), compared to what you see with Windows line breaks on Windows in Atom or Notepad, .. (visible empty line at end) |
Why do you think it would be visually inconsistent? |
Because Therefore, |
How does a file ending in |
It does actually not render as a separate trailing empty line in the Linux editors I checked, but that is a bug (since in Windows editors it WILL show up as a separate trailing empty line). Here is now a file with a single trailing This is how the exact same file shows up in Vim on Linux (without line space conversion): |
Yes it does – Atom shows a line, and vim doesn't. FWIW, VS Code also shows the line, as will a number of other editors. |
That's a good point. We should consider it when implementing atom/atom#7787 and ensure that we follow the correct practices on how this should be rendered on Windows. We don't want to not render the line if it should be rendered. Thank you for your comments @Jonast 🙇 Can you add a comment about the |
No it's not. |
I just mentioned VS Code, and I'm pretty sure that there are others (mostly GUI-based). |
vim follows POSIX, so each line must end with a newline. Windows editors (if I'm not mistaken), do not. So, there is no bug. |
The bug is that if a file with windows line breaks is shown, the Windows line breaks conventions should be followed. Or do you disagree? Otherwise, WIndows text files transferred without any alteration will show a different amount of lines in a Linux editor exhibiting this bug, although actually being the exact same file. |
vim etc. don't care about other operating systems, it shouldn't have to handle all cases. It only "knows" about |
I guess that could be one way to see it since Vim isn't cross-platform, but that doesn't necessarily make it a feature. If at all it would be an accepted limitation, but not correct behavior for treating Windows line breaks.. |
IMHO If Atom is in a Posix environment, it should follow the Posix environment. So if it saves the file in Posix format, it should show the file as it was saved, i.e in Posix format. Moreover if other editors don't show the trailing newline to follow the Posix standard, Atom should just do like them. This is consistency in my opinion. So why should we have an Editor that always shows to the user a line that doesn't exist in the saved file and in any other editor that reads that file in the same environment? |
Prerequisites
Description
The whitespace package setting "Ensuring Single Trailing Newline" appears to be broken: the trailing newline is misleadlingly shown in the editor as advertised, but not actually saved in the file on disk (which the description text seems to suggest, and which would IMHO be a much more reasonable behavior).
Since this is annoying for people using something like emacs/vim and I generally have a single trailing newline in my project which Atom is now breaking when I use it, it would be nice if this could be fixed.
Steps to Reproduce
Expected behavior: with "Ensuring Single Trailing Newline" enabled, I don't just see a newline in Atom but it's actually saved to disk as well
Actual behavior: no trailing newlines saved to disk, which is a problem when collaborating with other editor users to whom this is potentially an annoyance
Reproduces how often: 100% (every time)
Versions
Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.
The text was updated successfully, but these errors were encountered: