-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Implement trim_final_newlines
setting and functionality
#87099
Implement trim_final_newlines
setting and functionality
#87099
Conversation
d69a6c3
to
842b2d9
Compare
a8cc5ed
to
5c9ee56
Compare
5c9ee56
to
cb7ca79
Compare
Yeah, the selection code is more complex than it needs to be at the moment. Or if #86978 is merged first, you wouldn't have to worry about carets or selections at all, the |
That's awesome context @kitbdev! Thanks :D |
cb7ca79
to
825669b
Compare
@kitbdev I've just tested against this change, it all looks good, the errors have gone away and any caret issues seem to be resolved too. Thank you for taking all that on 🙌🏻 |
825669b
to
5a1599b
Compare
b37d294
to
f4e7e18
Compare
eda3e0e
to
f4e7e18
Compare
trim_final_newlines
setting and functionality
f4e7e18
to
822d769
Compare
822d769
to
b4c1634
Compare
Updated with Kitbdev's last comment. Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Thanks! |
Closes: godotengine/godot-proposals#8867
Currently in a draft state as I need to figure out the best method for collapsing carets that fall outside the removed area of text.
This PR implements the
trim_final_newlines
setting to reduce the newlines at the end of file to the expected 1 newline. This puts the built-in script editor on parity with other editors like Visual Studio Code and helps reduce stray lines making their way into user repos.Implementation
I've opted to remove all bar the last empty lines from the file, checking simply for length 0. It intentionally runs after the
trim_trailing_whitespace
as to consume lines that only contain whitespace characters as well. In the case thattrim_trailing_whitespace_on_save
is not enabled it will then trim all lines back to the line with whitespace, leaving that untouched with a single newline following.This relies on the functionality added in #86978 for caret and selection support.