Skip to content

Save removes whitespace at the start of a line #22179

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

Closed
lukechurch opened this issue Jan 28, 2015 · 9 comments
Closed

Save removes whitespace at the start of a line #22179

lukechurch opened this issue Jan 28, 2015 · 9 comments
Assignees
Milestone

Comments

@lukechurch
Copy link
Contributor

Repro:

main(List<String> args) {
<----
}

Enter at <---- correctly indents 4 chars.

Press Cmd + S, the cursor jumps back to the start of the line.

@lukechurch
Copy link
Contributor Author

Sorry, may that 2 spaces, not 4.

@DartBot
Copy link

DartBot commented Jan 28, 2015

This comment was originally written by [email protected]


If nothing follows that whitespace, that whitespace is at the end of the line.

Trailing whitespace is removed on-save if you've enabled this feature (Tools->Preferences->Editor->Save actions->Remove trailing whitespace).

@lukechurch
Copy link
Contributor Author

In which case the heuristic may need adjusting so that it doesn't strip whitespace off lines that are in the middle of the file that contain only whitespace.

@DartBot
Copy link

DartBot commented Jan 28, 2015

This comment was originally written by [email protected]


Stripping any trailing whitespace (even if there isn't anything other than whitespace) is the desired behavior. Other editors and IDEs do the same.

The only difference is that some editors (e.g. Netbeans 8.0.2) do not remove the whitespace in front of the cursor. Having this special case for the current line prevents that cursor-jump you were seeing.

I attached an image which illustrates the effect. I'm using a theme which uses a pink strike-through line to highlight trailing whitespace.


Attachment:
netbeans-trailing-whitespace.png (4.74 KB)

@lukechurch
Copy link
Contributor Author

Thanks - yes, I agree, that would also solve the most serious problem.

I'm still not terribly convinced that having whitespace stripping so that the indent doesn't match the natural indent is the right behaviour, but that is less important than the cursor jumping behaviour.

@clayberg
Copy link

Set owner to @scheglov.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@scheglov
Copy link
Contributor

@scheglov
Copy link
Contributor

@clayberg
Copy link

Added this to the 1.9 milestone.

This issue was closed.
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

No branches or pull requests

4 participants