Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 459341 - Format on save alternates between two layouts on each save
Summary: Format on save alternates between two layouts on each save
Status: CLOSED DUPLICATE of bug 439582
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-06 12:27 EST by Andrew Clement CLA
Modified: 2015-02-10 06:01 EST (History)
2 users (show)

See Also:


Attachments
Eclipse project showing issue (13.60 KB, application/zip)
2015-02-06 12:27 EST, Andrew Clement CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2015-02-06 12:27:46 EST
Created attachment 250595 [details]
Eclipse project showing issue

Not quite sure if I'm raising this against the right component...

I have a simple source file and format on save setup (with extra configuration). On first save the file turns into this:

===
package pkg;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

enum Color {
	RED, GREEN, BLUE
}


class SB {

	public SB addAll(Object o) {
		return this;
	}

	public SB build() {
		return this;
	}
}


public class RMB {

	private static final Set<Object> x = new HashSet<Object>(Arrays.asList(new Color[] {
		Color.RED,
			Color.GREEN,
		Color.BLUE
	}));

	private static final Object o = new SB()
	.addAll("ABC")
	.addAll("DEF")
	.addAll("GHI")
	.build();

}

===

On second save (just made a whitespace change in the file) the formatting in RMB flips to this:
===
public class RMB {

	private static final Set<Object> x = new HashSet<Object>(Arrays.asList(new Color[] {
			Color.RED,
		Color.GREEN,
			Color.BLUE
	}));

	private static final Object o = new SB()
			.addAll("ABC")
			.addAll("DEF")
			.addAll("GHI")
			.build();

}
===

Another whitespace change and it flips back to the first option, and so on - this is causing real issues for the team here as it constantly shows outgoing git changes when nothing is actually changing. I've attached a zip of the project containing this file and the ui/core prefs.

In terms of save actions I simply opened preferences and in saved actions set it to 'Perform the selected actions on save' and 'Format source code' 'format all lines'. The extra config in ui/core prefs files was supplied to me, I haven't dug into it to see which setting is triggering the problem.
Comment 1 Noopur Gupta CLA 2015-02-10 06:01:25 EST

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