Bug 311173 - Remove trailing whitespace on touched lines
Summary: Remove trailing whitespace on touched lines
Status: CLOSED DUPLICATE of bug 180349
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-30 09:45 EDT by anatoly techtonik CLA
Modified: 2020-10-16 09:07 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description anatoly techtonik CLA 2010-04-30 09:45:50 EDT
Build Identifier: 20100211-2030

Eclipse editor doesn't remove trailing whitespaces in source code and autoindentation even adds them. Trailing whitespaces are easily added when debugging. Debug code is added and removed, but whitespaces persist. This cause false differences when comparing revisions in source control history. Difference in whitespaces also produces merge conflicts between branches. These changes are always distracting and annoy developers, because they should be manually cared and removed on commits.

It may be tempting to propose edit mode that removes trailing whitespaces upon save, but this is not always on, not everybody on a project may use Eclipse, so this is not an option.

The proper behavior would be mode that strips trailing whitespaces only from edited lines.

See this question for some 13 votes - http://stackoverflow.com/questions/1043433/how-to-auto-remove-trailing-whitespace-in-eclipse

Reproducible: Always

Steps to Reproduce:
Just use autocompletion to type something like.
   function something() {

   }

   function anything() {

   }

and note trailing whitespace between and inside function bodies (PHP Tools at least).
Comment 1 Remy Suen CLA 2010-04-30 10:38:07 EDT
(In reply to comment #0)
> (PHP Tools at least).

I guess I'll move this to PDT. Platform/UI is for generic bugs in the Eclipse user interface related to views, editors (not text editors mind you, just the editor framework), and perspectives.
Comment 2 anatoly techtonik CLA 2010-04-30 13:05:35 EDT
I guess it is not only for PDT until it is validated that other editors (Java, JavaScript, Python, C++) can correctly strip whitespaces from edited lines.
Comment 3 Remy Suen CLA 2010-04-30 14:32:34 EDT
(In reply to comment #2)
> I guess it is not only for PDT until it is validated that other editors (Java,
> JavaScript, Python, C++) can correctly strip whitespaces from edited lines.

Platform/IDE is for generic IDE-related bugs like the 'Problems' view. If we're talking about text editors, it goes to Text.

The Java editor can delete trailing whitespace with its formatter. I'm not sure if there's a generic solution.
Comment 4 anatoly techtonik CLA 2010-04-30 15:45:51 EDT
Exactly. Generic solution is needed.
Comment 5 Remy Suen CLA 2010-04-30 15:49:31 EDT
I think you want bug 180349.
Comment 6 anatoly techtonik CLA 2010-04-30 16:01:50 EDT
No, the #180349 is about removing trailing whitespace globally in the file. This bug is about removing trailing whitespace from edited lines only.
Comment 7 Dani Megert CLA 2010-05-01 03:21:06 EDT
Remy is right, it's a duplicate of bug 180349. The save action would allow to scope the changes to the edited lines (see Java Save Actions for example).

*** This bug has been marked as a duplicate of bug 180349 ***
Comment 8 anatoly techtonik CLA 2010-05-18 10:53:30 EDT
Issue #180349 is a generalization that doesn't cover this specific case. Changing title, reopening and adding #180349 as dependency.
Comment 9 Dani Megert CLA 2010-05-18 11:51:46 EDT
This is what will happen with bug 180349 i.e. it will allow to only remove the trailing whitespace of touched lines.

*** This bug has been marked as a duplicate of bug 180349 ***
Comment 10 anatoly techtonik CLA 2010-05-18 12:55:46 EDT
(In reply to comment #9)
> This is what will happen with bug 180349 i.e. it will allow to only remove the
> trailing whitespace of touched lines.

Bug 180349 doesn't list this case. It seems that the original reporter meant that trailing spaces should be stripped globally when file is saved. If you clarify that in bug 180349 case, I will agree to close this ticket as duplicate and not as dependency.
Comment 11 Dani Megert CLA 2010-05-19 02:43:37 EDT
When solving a bug we also look at the duplicates, so there's no need for additional bloat in the other bug. If you don't trust that then you can also add a comment yourself there but please stop reopening this bug.

*** This bug has been marked as a duplicate of bug 180349 ***
Comment 12 anatoly techtonik CLA 2010-05-21 10:03:53 EDT
On the second thought I do not want whitespaces to be deleted upon save, but rather immediately if I leave the edited line. Should I reopen this bug?
Comment 13 Dani Megert CLA 2010-05-21 10:14:49 EDT
>On the second thought I do not want whitespaces to be deleted upon save, but
>rather immediately if I leave the edited line. Should I reopen this bug?
This would not be enough because whitespace would not be deleted for the current line when you save and close the editor, hence you need to have it on save.
Comment 14 anatoly techtonik CLA 2010-05-21 12:28:14 EDT
(In reply to comment #13)
> >On the second thought I do not want whitespaces to be deleted upon save, but
> >rather immediately if I leave the edited line. Should I reopen this bug?
> This would not be enough because whitespace would not be deleted for the
> current line when you save and close the editor, hence you need to have it on
> save.
Then whitespace should deleted from the current line, when editor freezes, loses focus or releases control. Or better - whitespaces should not be added until a symbol is entered in the middle of line.