Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 446240 - Formatter inappropriately stripping carefully added whitespace in variable declarations
Summary: Formatter inappropriately stripping carefully added whitespace in variable de...
Status: CLOSED DUPLICATE of bug 131292
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 4.9 RC1   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard: To be verified for 4.9 RC1
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-07 22:08 EDT by Alexander Ryan CLA
Modified: 2018-08-29 18:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Ryan CLA 2014-10-07 22:08:21 EDT
See the following unresolved issue on stack overflow:

http://stackoverflow.com/questions/11516623/stop-code-format-from-removing-whitespaces-in-eclipse


To reproduce
Add these local variables ...
        int ID         = 0;
        int OBJECT_ID  = 1;
        int SESSION_ID = 2;

Select to format.
Notice that eclipse changes the formatting and there does not appear to be an option to prevent this from happening.

        int ID = 0;
        int OBJECT_ID = 1;
        int SESSION_ID = 2;



A mechanism is provided to align variable declarations in columns, but this is restricted to class variables.

"Preferences: 
Java > Code Style > Formatter:
Indentation > Align class fields in columns"

There does not appear to be an option for local variables.

So my carefully formatted code gets wiped out whenever the the formatter is run.
Comment 1 Noopur Gupta CLA 2014-10-08 07:21:43 EDT

*** This bug has been marked as a duplicate of bug 131292 ***