Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 377914

Summary: Code formatter repeatedly adds newline before formatter:off region in enum declaration
Product: [Eclipse Project] JDT Reporter: Andre Bargull <andrebargull+eclipse>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, mateusz.matela, wigbam
Version: 3.8   
Target Milestone: 4.8 M6   
Hardware: All   
OS: All   
Whiteboard: To be verified for 4.8 M6

Description Andre Bargull CLA 2012-04-27 09:57:03 EDT
Build Identifier: Version: Indigo Service Release 2 Build id: 20120216-1857

Whenever the code format action is triggered, the formatter adds another newline before the `//@formatter:off` comment. I'm using a slightly modified version of the "Eclipse [built-in]" code formatter settings. To reproduce the bug the following two options need to be changed:
- Line Wrapping > 'enum' declaration > Constants > Policy -> "Wrap where necessary"
- Off/On Tags -> Enabled

And here's the code in question:
---
package bugs;

public class EclipseFormatBug {
  enum MyEnum {
    // @formatter:off
    someEnumConstantWithLongName,
    anotherEnumConstantWithAnEvenLongerName,
    stillAnotherEnumConstant;
    // @formatter:on
  }
}
---

Reproducible: Always
Comment 1 Stepan Kolesnik CLA 2014-08-20 05:46:56 EDT
This bug is still present in the 4.4 release.
Comment 2 Mateusz Matela CLA 2018-02-05 16:26:11 EST
This problem no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 3 Manoj N Palat CLA 2018-03-08 05:43:56 EST
Verified for Eclipse Photon (4.8) M6 with Build id: I20180306-0800