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

Bug 438942

Summary: Auto indent puts 4 sapces after parentheses while indent is set to 2 space
Product: [Eclipse Project] JDT Reporter: Amir Karimi <a.karimi.k>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: manju656, markus.kell.r
Version: 3.8   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Amir Karimi CLA 2014-07-04 12:46:31 EDT
I've changed the indention for Java formatter to 2 spaces. But auto indention put 4 spaces when I hit enter after a parenthesis;

Ok(
    _ <- Caret is here
)

But I have no problem with braces;

def A = {
  _ <- Caret is here 
}

I code in Scala but the problem is produced in Java as well.
Comment 1 Martin Mathew CLA 2014-07-14 01:45:18 EDT
[1] System.out.println(|); Press 'Enter' at location marked with | gives:
System.out.println(
    |);
[2] new Runnable() {|}; Press 'Enter' at location marked with | gives:
new Runnable() {
  |
};
On analysis, the indentation after parenthesis is computed in JavaIndenter#createReusingIndent => fPrefs.prefIndentationSize * additional where:
fPrefs.prefIndentationSize =>  'Indentation size' from the 'Indentation' tab 
additional => 'Default indentation for wrapped lines' from the 'Line Wrapping' tab.

If 'Default indentation for wrapped lines' from the 'Line Wrapping' tab is set to '1', then case [1] behaves same as case [2].

@Markus: Is this the intended behavior?
Comment 2 Amir Karimi CLA 2014-07-15 04:13:40 EDT
@Manju - Thanks! Setting 'Default indentation for wrapped lines' to 1 solved the problem. It was 2 by default.
Comment 3 Markus Keller CLA 2014-07-15 09:37:38 EDT
> @Markus: Is this the intended behavior?

Yes.