Bug 448850 - Incorrect indentation after ternary operator (x ? y : z)
Summary: Incorrect indentation after ternary operator (x ? y : z)
Status: CLOSED DUPLICATE of bug 65463
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.4.1   Edit
Hardware: PC Linux
: P3 minor with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact: Manoj N Palat CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-25 15:26 EDT by Gabor CLA
Modified: 2019-02-12 10:14 EST (History)
3 users (show)

See Also:


Attachments
Problem cases for an Indentation issue with the ternary operator (5.18 KB, text/plain)
2014-10-25 15:26 EDT, Gabor CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor CLA 2014-10-25 15:26:13 EDT
Created attachment 248181 [details]
Problem cases for an Indentation issue with the ternary operator

Issue:
    incorrect indentation in Java after ternary operator (x ? y : z)

Version of Eclipse:
    - Luna 4.4.1, Build id: 20140925-1800, Linux 32-bit
    - Build 20140925-1800 for Windows 7 shows the same behaviour
    - workspace with default settings

Example (showing the left margin)
    Expected outcome:
        |String res = condition
        |        ? bar() : bar();
        |proof_of_pudding();

    Actual outcome:
        |String res = condition
        |        ? bar() : bar();
        |        proof_of_pudding();  // <--- incorrect

Remarks
    - The problem appears to require two conditions:
      (i)  the `then' branch ends with a closing parenthesis, a closing square
           bracket or a closing curly brace;
      (ii) at least one of the following three conditions holds:
           (ii-a) there is a line break after the assignment operator (=);
           (ii-b) there is a line break before the question mark;
           (ii-c) there is a line break after the question mark.
    - Attached please find a file with a number of problem cases.  These should
      cover all combinations of newline placements where the indentation goes
      wrong.
    - Please notice the odd position of the colon if it follows a curly brace
      and a newline (from line 250 on in the attached file).

Thank you in advance for looking at this issue.

Regards,
G.
Comment 1 Dani Megert CLA 2019-02-12 10:14:20 EST

*** This bug has been marked as a duplicate of bug 65463 ***