This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version = NetBeans IDE 7.2 (Build 201207171143) Operating System = Linux version 3.0.0-23-generic-pae running on i386 Java; VM; Vendor = 1.6.0_24 Runtime = OpenJDK Client VM 20.0-b12 [Early use after 7.2 upgrade] Sample code: <?php if (true) { ; } else { ; } if (true) ; // <== No code fold option else { ; } if (true) { ; } else ; // <== No code fold option ?> When curly braces used the whole statement is folded Without curly braces no code fold option. ** Note: There is more to this than meets the eye ** When the test file was first created all the closing curly braces were indented, even after formatting, and only the else statements without curly braces did not fold. Formatting a pre-7.2 file did not indent the closing curly braces. After playing with format options closing curly braces are correctly aligned with the if and now both the if and else clauses without curly braces do not fold. Also something wrong in the way options are being imported/used??
Created attachment 122482 [details] IDE log
Update: Checking further, In the case of no curly braces .. The if clause will fold if not empty (just a ;). The else clause will not fold whether empty or not. Folded block appears on the next line. In the case of curly braces .. Folded block appears at the end of the line.
I'm a bit confused from your report :) So what is a mistake? That statements without curly braces can't be folded? But afaik it's intended, because they are not blocks. We enable code folding for blocks, not for on-line statements. Or you think that we should enable folding for one-line statements as well?
Thinking back (this was lodged nearly two months ago).. Please re-read Comment #2 carefully. The issue is not whether code folding should apply to statements without curly braces, it is that it is not handled consistently.
(In reply to comment #2) > Update: > Checking further, > > In the case of no curly braces .. > The if clause will fold if not empty (just a ;). > The else clause will not fold whether empty or not. ...yes I can reproduce that in 7.3dev. I'll try to fold it as well. > Folded block appears on the next line. > > In the case of curly braces .. > Folded block appears at the end of the line. Not exactly...the folded block is in the place of opening brace (block opening), or in the place of statement start in case without curly braces (with just one statement). So if you use: <?php if () { } ?> then folded block will be: <?php if () [{...}] ?> It can't be the same for "braced" block and statements without a braces. But everytime it's the start of the folded "block/statement".
Else can be folded as well. Fixed in web-main #401a13ec947e
Integrated into 'main-golden', will be available in build *201211060001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/401a13ec947e User: Ondrej Brejla <obrejla@netbeans.org> Log: #216088 - Code folds on if else without curly braces, and strange formatting behaviour