Bug 219614 - [formatter] does not remove trailing spaces if more then 11 spaces
Summary: [formatter] does not remove trailing spaces if more then 11 spaces
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-20 11:15 EST by Adrien Rivard CLA
Modified: 2011-09-14 11:19 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 Adrien Rivard CLA 2008-02-20 11:15:08 EST
Build ID: I20071213-1700

Steps To Reproduce:
1.preferences>java>editor>save actions :select 'perform the selected action on save', select 'format source code' , and select and format edited line. 
2.add some whitespace at the end of any java line and save.> the line in formatted but the trailing spaces are still there.

Note that it work correctly if 'format all lines' is selected or with the normal format action.


More information:
Comment 1 Dani Megert CLA 2008-02-20 11:16:45 EST
Benno, please investigate.
Comment 2 Benno Baumgartner CLA 2008-02-21 04:25:23 EST
I can not reproduce, neither in HEAD nor in 3.4 M4. Please provide exact steps: How does the code look like you are trying to format? Can you provide an example? What are your formatter settings? Can you attach your formatter profile? Does this happen in 3.4 M5 too?

Thanks.
Comment 3 Adrien Rivard CLA 2008-02-21 05:34:50 EST
Had a hard time to reproduce with a clean workspace/project  but finally got something. It seems to depends on the location of the wihtespaces/lengh of the file :
with a class like that 
public class test {

	public static final String addingherework = "t";

	public static final String shortbefore2 = "t";    
	
	public static final String toto = "adding spaces here don't work";    
  	
	public static final String shortAfter = "t";   
	
}



If I add some whitespaces after the first attribute  line they are correctly discarded while if I add some at the third attribute line they are not discarded...

That  is with M4 , defaults settings except for the few  'save actions' ones.
Comment 4 Benno Baumgartner CLA 2008-02-21 10:59:02 EST
Thanks! Very strange.

Given fresh workspace:
public class Test {
	public static final String addingherework = "";
}
1. Add 11 (or less) spaces after the ';'
2. Select the complete line with the field, from start to end, including spaces
3. Source>Format
Is: Trailing spaces are removed
4. Add 12 (or more) spaces after the ';'
5. Select the complete line with the field, from start to end, including spaces
6. Source>Format
Is: Trailing spaces stay

Hint1: For testing you can enable show whitespace characters in the preferences
Hint2: Format edited line has the same problem, it's the same code

I've verified that we call DefaultCodeFormatter.format(int, String, IRegion[], int, String) with the same options in both cases (except of course the region which have a different length)

Moving to core

Comment 5 Frederic Fusier CLA 2009-10-02 10:43:17 EDT
It works since 3.5.0. I guess this is a consequence of the fix for bug 234583...
Comment 6 Olivier Thomann CLA 2011-09-14 11:19:27 EDT
Verified.