Community
Participate
Working Groups
Update to version 2020-03 (4.15.0) came down and I've noticed "selection formatting" (Source > Format, with a line selected in the editor) now adds strange line breaks. This makes Propertes > "Java Editor" > "Save Actions" > "Format source code" > "Format edited lines" mostly unusable. To demonstrate, here's a bit of formatted code: ``` import java.util.Arrays; import java.util.Collection; public class Test { public static void main(String[] args) { boolean y = Arrays.asList(1, 2).stream() .map(Arrays::asList) .flatMap(Collection::stream) .map(Arrays::asList) .filter(x -> true) .map(Arrays::asList) .anyMatch(x -> true); } } ``` Again, this is already formatted and formatting again does not change anything. As such, it's expected formatting lines individually should also not change anything. (And this was the case in version 2019-09.) However, if I select the 7th line and format, it changes to this: ``` boolean y = Arrays.asList(1, 2) .stream() ``` If I select the top line of this new code and format, it changes further to this: ``` boolean y = Arrays.asList(1, 2) ``` If I select the 9th line of the original code and format, it changes to this: ``` .flatMap( Collection::stream) ``` For all other lines, selecting and formatting does not change anything. # Steps to reproduce 1. Download "Eclipse IDE for Java Developers" (2020-03 R) from https://www.eclipse.org/downloads/packages/ 2. Unzip the package and run eclipse 3. Create a new Java Project (I selected JavaSE-1.8) 4. Create Text.java and paste the above code. 5. Open Preferences > Java > Code Style > Formatter > Edit... and enable "Line Wrapping" > "Never join already wrapped lines" then save to a new profile. (This should produce formatting based on "Eclipse [built-in]" which is the minimum required to produce the above code formatting.) 6. Perform Source > Format without selecting any code to ensure nothing changes. 7. Select the `boolean y = Arrays.asList(1, 2).stream()` line and perform Source > Format.
*** This bug has been marked as a duplicate of bug 560889 ***