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

Don't automatically trim trailing whitespace on the current line #34701

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Dec 30, 2019

This prevents the cursor from moving unexpectedly when saving a file.

"Trim Trailing Whitespace On Save" is now enabled by default, as this change makes it much more convenient to use.

Manual whitespace trimming operations (such as using the menu option) will still trim trailing whitespace on the current line.

This prevents the cursor from moving unexpectedly when saving a file.

"Trim Trailing Whitespace On Save" is now enabled by default,
as this changes makes it much more convenient to use.

Manual whitespace trimming operations (such as using the menu option)
will still trim trailing whitespace on the current line.
@Calinou Calinou force-pushed the trim-trailing-whitespace-no-current branch from a672240 to 5d36dbb Compare December 30, 2019 15:40
@Calinou Calinou changed the title Don't automtaically trim trailing whitespace on the current line Don't automatically trim trailing whitespace on the current line Dec 30, 2019
@akien-mga akien-mga requested a review from Paulb23 December 30, 2019 17:17
Copy link
Member

@Paulb23 Paulb23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't looked at the code, but I would expect it to remove all whitespace regardless of caret placement (seen in QTCreator, Kate and Sublime Text.).

However, Intellij contains an option to ignore lines that contain a caret, don't know if its worth going down that route?

@akien-mga
Copy link
Member

akien-mga commented Dec 31, 2019

I would also expect the trimming to happen on all lines, regardless of which one has the caret. It might be a mild allowance if you type some code, press Return to go to the next line (indented automatically), and then save, thus losing indentation, but apart from that, I don't see much need to make this optional.

What are the situations you saw where whitespace trimming would be problematic on the line with the caret?

@Calinou
Copy link
Member Author

Calinou commented Dec 31, 2019

What are the situations you saw where whitespace trimming would be problematic on the line with the caret?

When you enable whitespace trimming on save, it requires you to reindent the line you were working on after saving (if it's a blank line). For instance, JetBrains IDEs will never trim whitespace on the current line. That said, saving is automatic in those IDEs, so you usually never press Ctrl + S in the first place.

On the other hand, it's true that many IDEs trim whitespace on the current line when you enable the option to trim it when saving (like Visual Studio Code).

@Calinou Calinou added this to the 4.0 milestone Mar 12, 2020
@YuriSizov YuriSizov requested a review from a team August 24, 2021 22:33
@Paulb23
Copy link
Member

Paulb23 commented Aug 30, 2021

Based on the above might be worth closing, and seeing if users want this as a setting via a proposal?

@Calinou
Copy link
Member Author

Calinou commented Aug 30, 2021

Closing in favor of godotengine/godot-proposals#3229.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants