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

Bug 336531

Summary: [formatter] comment containing formatter:off tag gets wrongly indented when Maximum line width>=90
Product: [Eclipse Project] JDT Reporter: Lukas Felber <l.felber>
Component: CoreAssignee: JDT Core Triaged <jdt-core-triaged>
Status: CLOSED WONTFIX QA Contact: Ayushman Jain <amj87.iitr>
Severity: trivial    
Priority: P3 CC: amj87.iitr
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug
Attachments:
Description Flags
Java Code Formatter Profile none

Description Lukas Felber CLA 2011-02-07 11:25:32 EST
Build Identifier: I20100608-0911

if the text/code in between of my off and on tag is "short", the comment containing the off tag gets formatted (indentation removed) even if it shouldn't (according to the "Off/On Tags" preference page).
I do not exactly know what the text length limit is that causes the formatter to miss-function, but the example below should explain the problem

Reproducible: Always

Steps to Reproduce:
//formatting the the following code will cause the removal of the indentation of the comment "//@formatter:off"...

@RunWith(Suite.class)
@SuiteClasses({
			//@formatter:off
			A.class,
			A.class,
			A.class,
			A.class,
			A.class,
			A.class,
			A.class,
			A.class,
			A.class
			//@formatter:on
})
public class A {
}

// ... whereas in the following sample it wont

@RunWith(Suite.class)
@SuiteClasses({
			//STOP-ECLIPSE-FORMATTING
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class,
			AAAAAAAAAAAAAA.class
			//START-ECLIPSE-FORMATTING
})
public class AAAAAAAAAAAAAA {
}
Comment 1 Lukas Felber CLA 2011-02-07 11:28:55 EST
the example contains a little mistake. The second example should also contain "@formatter:off" / "@formatter:on" instead of "STOP-ECLIPSE-FORMATTING
" / "START-ECLIPSE-FORMATTING".
Comment 2 Ayushman Jain CLA 2011-02-08 02:27:40 EST
I couldn't reproduce the problem. Can you please use a newer build and check again? Thanks.
Comment 3 Lukas Felber CLA 2011-02-08 03:46:25 EST
On the current nightly build (7.2.2011) the problem is not existing anymore.
However, the current stable version 3.7M5 still contains the problem.

Seems that the problem was solved somehow (either this ticket is a duplicate or the problem vanished alongside another bug/bugfix).
Comment 4 Ayushman Jain CLA 2011-02-08 04:07:17 EST
(In reply to comment #3)
> On the current nightly build (7.2.2011) the problem is not existing anymore.
> However, the current stable version 3.7M5 still contains the problem.

I'm trying this on M5 and still can't see the problem. There's nothing we did on the formatter post M5. So this doesnt look like an M5 issue either if the current nightly build is fine.
Comment 5 Lukas Felber CLA 2011-02-08 06:35:45 EST
Created attachment 188508 [details]
Java Code Formatter Profile

Now I'm getting a bit confused. I downloaded 3.6, 3.7M1, 3.7M5 and the last nightly and cannot reproduce the problem on any of them what got me pretty confused.

I figured out however, that the formatter configuration causes the problem.

So after importing the javaFormatter.xml (which is attached), the problem should be reproducible.
Comment 6 Ayushman Jain CLA 2011-02-08 07:40:00 EST
(In reply to comment #5)
> Created attachment 188508 [details] [diff]
> Java Code Formatter Profile

Thanks. Now I can reproduce iff I use the above profile AND turn on the on/off tags AND make sure that class name contains more than 2 A's.

The only difference in this profile from the built in profile is in the Formatter>Line wrapping>Maximum line width setting. When this is set to >= 90, only then this bug shows up.

Will investigate, time permitting.
Comment 7 Eclipse Genie CLA 2019-09-07 17:22:52 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.