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.

Bug 216088 - Code folds on if else without curly braces, and strange formatting behaviour
Summary: Code folds on if else without curly braces, and strange formatting behaviour
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-28 00:12 UTC by berniev
Modified: 2012-11-06 03:10 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (32.59 KB, text/plain)
2012-07-28 00:12 UTC, berniev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description berniev 2012-07-28 00:12:39 UTC
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??
Comment 1 berniev 2012-07-28 00:12:46 UTC
Created attachment 122482 [details]
IDE log
Comment 2 berniev 2012-07-28 00:24:17 UTC
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.
Comment 3 Ondrej Brejla 2012-09-20 11:01:11 UTC
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?
Comment 4 berniev 2012-09-20 12:38:31 UTC
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.
Comment 5 Ondrej Brejla 2012-11-05 10:40:44 UTC
(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".
Comment 6 Ondrej Brejla 2012-11-05 12:13:29 UTC
Else can be folded as well.

Fixed in web-main #401a13ec947e
Comment 7 Quality Engineering 2012-11-06 03:10:26 UTC
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