Community
Participate
Working Groups
Build Identifier: 20100218-1602 If you enter a new line at various points in the middle or after the ternary statement, the indentation of the newline is wrong. It may only happen if done as part of a method argument (or possibly even if it is a vararg??) In the following example, the second line "true)'" should not be indented so far: printf("%s %d", true ? "TRUE" : "FALSE", true); Also if you enter a new line after the colon ':' the indentation seems to be wrong too: printf("%s %d", true ? "TRUE" : "FALSE", true); Lastly if you enter a new line after the colon ':': printf("%s %d", true ? "TRUE" : "FALSE", true); Reproducible: Sometimes Steps to Reproduce: 1. use a ternary operator as a method argument 2. after the comma, press the enter key to create a new line 3. the new line is indented incorrectly
(In reply to comment #0) > Build Identifier: 20100218-1602 Please clarify the CDT version you are using.
Build Identifier was for Eclipse. The CDT details are: Eclipse C/C++ Development Tools Version: 6.0.2.201002161416 Build id: 201002161416
This seems to work for me. The new line is indented 2 levels deeper (the default line continuation indent) regardless where I press enter. If you are using a custom code style, please attach it here (as exported XML file). Try also a newer version of CDT, you won't get a fix in the 6.0.x stream anyway.
Ok, I'll try the newer version. Note that I didn't even realise there was a newer version - I've been using Eclipse's "Check for updates" and it says there are none. I guess it doesn't compare completely different releases of eclipse or major version changes to plugins... Instead I've subscribed to the eclipse downloads RSS feed to keep up to date.
Issue: incorrect indentation after ternary operator Version of Eclipse: - Luna 4.4.1, Build id: 20140925-1800, Windows 7 - 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 be triggered by two conditions on the `then' branch of the ternary expression: (i) the `then' branch is to a new line (no matter whether the break is before or after the question mark); (ii) the `then' branch ends with a closing parenthesis. - Attached please find a file with a number of test cases. Thank you in advance for looking at this issue. Regards, G.
Created attachment 248137 [details] Test cases for indentation issues of the ternary operator
(In reply to Gabor from comment #6) > Created attachment 248137 [details] > Test cases for indentation issues of the ternary operator This attachment is a Java file. This bug concerns the C++ formatter (as it's in the CDT product). Is it possible you meant to comment in (or file) a bug in the JDT product instead?
> Is it possible you meant to comment in (or file) a bug in the JDT product > instead? It absolutely *is*. Feel free to ignore/remove my report, I'll re-post it for JDT. Regards, and sorry for the pollution, G.
Closing per comment 3. Feel free to reopen if you're still seeing this.