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

Bug 482413

Summary: [formatter] Erroneous formatting for left curly brace on line wrap
Product: [Eclipse Project] JDT Reporter: John Vines <jvines>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, manoj.palat, mateusz.matela, noopur_gupta
Version: 4.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description John Vines CLA 2015-11-17 14:41:29 EST
The behavior of formatting brace placement when a line wraps seems to be erroneous, or at least not configurable.

What I'm getting-
          if (!longConditionalCheckOfWhichOnlyOneCanFitOnALineAndForcesAWrap(argument1, argument2) ||
            !longConditionalCheckOfWhichOnlyOneCanFitOnALineAndForcesAWrap(argument1, argument2))
        {
            doSomething();
          }

What I expect
          if (!longConditionalCheckOfWhichOnlyOneCanFitOnALineAndForcesAWrap(argument1, argument2) ||
            !longConditionalCheckOfWhichOnlyOneCanFitOnALineAndForcesAWrap(argument1, argument2))
          {
            doSomething();
          }

In my formatter, I have Braces->Blocks set to next line on wrap. If I set it to next line, I get the correct behavior here (but then it will always go on the next line which I don't want). I would expect these two different settings to have the same behavior on lines which wrap, and that is currently not the case.
Comment 1 Mateusz Matela CLA 2015-11-18 16:54:29 EST
I don't see this effect. There are probably some other settings or surrounding code that affects this bug. Can you try to reproduce the bug starting with a fresh workspace and write down more details?
Comment 2 John Vines CLA 2015-11-18 17:14:00 EST
It must have been an issue with the file at the time of formatting. I went back to try and repro it in a new workspace and I couldn't even get the original troublesome line to do it again.