Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 434962 - [formatter]Consecutively applying format keeps changing the code layout
Summary: [formatter]Consecutively applying format keeps changing the code layout
Status: VERIFIED DUPLICATE of bug 439582
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Linux
: P3 normal with 10 votes (vote)
Target Milestone: 4.5   Edit
Assignee: Manoj N Palat CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-15 09:21 EDT by Alexander Karatarakis CLA
Modified: 2015-08-13 08:15 EDT (History)
15 users (show)

See Also:


Attachments
Project with predefined formatting settings (4.55 KB, application/zip)
2014-05-15 09:21 EDT, Alexander Karatarakis CLA
no flags Details
First (and expected) outcome of save actions (219.43 KB, image/png)
2014-05-15 09:22 EDT, Alexander Karatarakis CLA
no flags Details
Second (and not expected) outcome of save (221.40 KB, image/png)
2014-05-15 09:23 EDT, Alexander Karatarakis CLA
no flags Details
Example of toggling code layout (81.54 KB, image/png)
2014-07-02 08:02 EDT, Fex Brown CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Karatarakis CLA 2014-05-15 09:21:49 EDT
Created attachment 243125 [details]
Project with predefined formatting settings

I have Save Actions that format the source code according to predefined settings. The layout of the code is not consistent, flipping between the attached Save1.png, Save2.png.

To reproduce:
1) Use the attached project. It has the formatting settings and save actions defined. The only class is Formatter.java.
2) Make a trivial change, like adding a whitespace somewhere and then Save. 
3) Repeat

Each time, the formatter will format the code differently. 

If I go to Save Actions->Configure->Code Organizing and uncheck "Correct Indentation", then the issue seems to disappear, namely the format will consistenly be the one shown in Save1.png.
Comment 1 Alexander Karatarakis CLA 2014-05-15 09:22:42 EDT
Created attachment 243126 [details]
First (and expected) outcome of save actions
Comment 2 Alexander Karatarakis CLA 2014-05-15 09:23:26 EDT
Created attachment 243127 [details]
Second (and not expected) outcome of save
Comment 3 Manoj N Palat CLA 2014-05-19 02:02:56 EDT
I will take a look
Comment 4 Alexander Karatarakis CLA 2014-06-03 09:52:38 EDT
Still an issue in 4.4 RC2
Comment 5 Manoj N Palat CLA 2014-06-03 23:14:56 EDT
(In reply to Alexander Karatarakis from comment #4)
> Still an issue in 4.4 RC2

Target milestone is 4.5. Will be fixed post Luna.
Comment 6 Fex Brown CLA 2014-07-02 08:02:39 EDT
Created attachment 244731 [details]
Example of toggling code layout

Another example of toggling code layout. On each save the code layout toggles between the two states.
Comment 7 Fex Brown CLA 2014-07-02 08:05:57 EDT
Added another example.

This issue is really annoying for our team. Real changes are hidden behind a lot of noise.

It's a pity that this known bug made its way through all RCs. Is there a possible workaround? Does someone know if changing some formatter settings helps?
Comment 8 Alexander Karatarakis CLA 2014-07-02 08:22:00 EDT
My current workaround: Go to Save Actions->Configure->Code Organizing and uncheck "Correct Indentation".
Comment 9 Elad Cohen CLA 2014-07-24 11:24:24 EDT
I have the same issue. It seam's to happens when I add a line comment on the end of the line. Alexander your work around didn't work for me.

Can you fix it please as fast as possible? Maybe you can release a hot fix before the next release? It cause us troubles when we committing the code to repository.
Comment 10 Elad Cohen CLA 2014-07-24 11:31:03 EDT
*It seems that it happens
Comment 11 Dirk Roesler CLA 2014-08-21 10:45:41 EDT
This is really annoing if you use the format on save to keep the source code consistent between developers in the source repository to identify changes easily.
Comment 12 Manoj N Palat CLA 2014-08-27 07:04:35 EDT
Added an offshoot bug 442689
Comment 13 Manoj N Palat CLA 2014-08-27 23:27:31 EDT
Adding bug 439582 as a dependent since bug 442689 is tagged as its duplicate.
Comment 14 Jorge Coelho CLA 2014-10-02 11:05:05 EDT
Here's a screen capture of how "Correct Indentations" messes with indentation during a save.

https://www.youtube.com/watch?v=0N4x_z6YEXY
Comment 15 Mariusz Pala CLA 2014-12-11 05:28:29 EST
This is really annoying issue and a fix in 4.5 is not enough, this is a critical issue.
Comment 16 Manoj N Palat CLA 2014-12-17 00:05:41 EST
(In reply to Mariusz Pala from comment #15)
> This is really annoying issue and a fix in 4.5 is not enough, this is a
> critical issue.

Please see bug 439582 comment 4. This is found to be a duplicate of bug 439582 instead of being dependent on that bug.

*** This bug has been marked as a duplicate of bug 439582 ***
Comment 17 Sasikanth Bharadwaj CLA 2015-05-19 03:06:04 EDT
Verified for 4.5 RC1 using 20150514-1000 build