Eclipse - Wrapped lines' indentation appears & disappears each time I save
Asked Answered
D

2

5

Each time I click Save the entire file's formatting alternates between these two formats:

this.getObject()
        .method()
        .method();
this.method(arg1, arg2,
        arg3, arg4);

and

this.getObject()
.method()
.method();
this.method(arg1, arg2,
arg3, arg4);

I want it to stick to the first format.

Daybreak answered 23/4, 2014 at 11:8 Comment(0)
T
10

I have the same problem with my current Eclipse configuration. I think it is an Eclipse bug.

My guess is that the problem is somewhat related to the option:

Java Code Style -> Cleanup -> Code organizing -> Correct indentation

getting in conflict with

Java Code Style -> Cleanup -> Code organizing -> Format source code

which should already fix indentation according to formatter settings.

I disabled the option Correct indentation in both Java Code Style -> Cleanup and Java Editor -> Save Actions -> Additional Actions -> Configure... and the problem seemed to disappear.

Thunderbolt answered 31/8, 2014 at 12:1 Comment(1)
This didn't help in my case. Any idea if the Check: Remove trailing whitespace / Radio: All lines could be the culpritVenenose
W
0

You may have to correct your existing code format from

Eclipse preferences > Java > code style > Formatter

Or if the current formatter is messing up, you could uncheck the auto formatting option during save using

Eclipse preferences > Java > Editor > Save Actions - UnCheck Format source code.
Weigle answered 23/4, 2014 at 11:22 Comment(1)
I want the formatter. Once formatted, there is no reason it should change each time I re-save the exact same file.Daybreak

© 2022 - 2024 — McMap. All rights reserved.