Skip to content

Clean Up Whitespace on Enter #128808

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ssigwart
Copy link
Contributor

Clean up whitespace when Enter key is pressed. This will:

  1. Remove all whitespace lines when you hit Enter.
  2. Remove whitespace from the end of something like "abc"; when you hit Enter.
  3. Remove the space before the 2 if you hit Enter after the comma in 1, 2. (This also works for multi-cursor mode)

This PR fixes #61972.
It might also be a workaround for #13157 because it will remove whitespace on the lines you modify, not the whole file.

To test, you can run this:

./scripts/test.sh --glob **/cursor.test.js --grep trimTrailingWhitespace

You can also manually test by adding whitespace at the end of lines and clicking Enter.

@CelticMinstrel
Copy link

2 and 3 sound good but I don't like the sound of 1. I prefer my blank lines to match the prevailing indentation.

@ssigwart
Copy link
Contributor Author

ssigwart commented Sep 4, 2021

@CelticMinstrel, I'm not going to make any changes to this pull request until I hear from the VSCode team, but I did update my extension with an option to allow all blank lines. Since this can be accomplished with an extension and people are going to want it handled different ways, there's a chance this gets closed instead or merged.

@alexdima alexdima self-requested a review November 16, 2022 13:36
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.

Strip trailing whitespace after the cursor when pressing enter
3 participants