-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Suppress display of end-of-file newline as blank line #1027
Comments
While I agree that files should have a new line at the end, wouldn't forcing this disallow saving files without the terminating new line character? |
@Tyriar This has no effect on file saving, it's just about the display of line numbers. |
So the line would still be there, just not the line number? |
Yes, but it's not technically a "line", it's just an area that can receive focus for text entry.
|
@alexandrudima what is your opinion? |
IMHO not rendering the last line number would be confusing, both for users and extension authors, as the last line can be interacted with (e.g. an extension can create edits on it, asking for line count at the API level would return it). @glen-84 I really like the brief technical explanation from POSIX, but then if I understand correctly:
Perhaps the intent of the issue is that the editor should never lead to a situation where a file is not terminated with a newline. In that case, I would treat the end of file newline in a similar way we treat the UTF8 BOM. The BOM is completely hidden in the model (cannot be interacted with or moved whatsoever) and when the workbench calls |
I can agree that some users would need to adjust to the change, because they may not be used to it. However, I still feel that it is the correct interpretation, as a line is defined as a series of non-newline characters followed by a newline character, which means that "row" 4 is not a line as defined, but merely a UI affordance (an area that can be focused in order to enter new lines of text).
A UI area that represents no backing content. No characters, including newlines, are represented. In my understanding, it's essentially not part of the file.
That may be the same way that VIM handles it. If I enter "Test" into a new file, and save, it saves with a trailing newline:
If you open the file, it displays This may be an even better way of handling it, so you wouldn't even be able to navigate to the 4th row without hitting enter, which might make more sense and be easier for users to understand. I prefer this actually. |
As this option is not configurable, there is no easy way to prevent 'No newline at end of file' warnings when using Git in merges (or just when reviewing commits). |
@peterblazejewicz This issue is more about the display (or lack thereof) of the final newline, and not its insertion. i.e. Don't render a numbered blank line at the end of files. |
@glen-84 Agreed. This is how vim does it too. |
Coming from Vim, I'm also searching for an option that will automatically save a More history at https://robots.thoughtbot.com/no-newline-at-end-of-file |
Moving this back to editor, neither I nor the issue creator agrees on the change of summary. I think this should be a setting that only has an impact on how the display behaves, not how the file is saved. |
Any update here? If this is not going to be changed in core is anyone aware of an extension that can prevent display of the last line like no-evil-eol-newline does for Atom? |
I tried adding the settings Coming from vim as well, would be nice to have a |
This is an annoying issue for people used to the behavior of most Linux text editors. There should be an option to suppress last blank line display. |
Just like vim does by default. Also it has a binary mode |
@alexandrudima Cursor can still move to a line without line number. Is this expected? If so please remove the verification-found label. |
Yes, that is expected. (we must respect existing API and extensions can place a cursor there, make edits there, etc.). |
This change doesn't affect Windows, correct? Verified with Ubuntu. |
@alexr00 It does if you set |
@glen-84, thanks! Verified on Windows too. |
Why is it not default |
I here to say I hated this "breaking" change. I spent a whole day frustrated looking for the correct setting to I'm used to. You shouldn't change something people expect unconsciously to be there without notice. |
The code in the merged PR returns an empty line number when the line content is an empty string, instead of when it doesn't end with a Also, shouldn't this be Finally, I think that (to make it less confusing for users used to the old behaviour), an optional display character to indicate that the previous line ends with a |
Currently:
What it should be:
Row 4 is not considered a line, at least not according to the POSIX definition, so it shouldn't be numbered.
(Atom issue here)
Edit: You might also consider not showing the final line number unless the line is correctly terminated, or, displaying an icon as suggested in this comment. However, this might "upset" certain users, so it should probably be configurable.
The text was updated successfully, but these errors were encountered: