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 179462 - Code folding folds too much
Summary: Code folding folds too much
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal (vote)
Assignee: rmatous
URL:
Keywords:
: 180690 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-13 10:21 UTC by lathspell
Modified: 2010-04-22 04:26 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lathspell 2010-01-13 10:21:31 UTC
Hello

When opening a PHP file with Code Folding enabled, by default everything
is folded into one line. That does not make much sense. When opening the first
fold even complete classes are folded although the configuration says that only
methods inside a class should be folded seperately.

My settings in Tools -> Options -> General -> Code Folding are:
  Use Code Folding: [x]
  Collapse by Default: 
    [x] Methods               [ ] Tags and Other Code Blocks
    [ ] Inner Classes
    [ ] Imports
    [ ] Javadoc Comments
    [ ] Initial comments

bye,

-christian-
Comment 1 msolanka 2010-02-21 05:22:26 UTC
I can confirm the same issue.
Product Version: NetBeans IDE 6.8 (Build 200912041610)
Comment 2 berniev 2010-02-23 11:22:27 UTC
I've just installed NetBeans IDE Dev (Build 201002220200) on Linux
and confirm this issue hasn't yet gone away. All fold levels are initially folded.
Comment 3 berniev 2010-02-23 11:49:59 UTC
It's actually more weird than that. Yes, initially all folds are closed, but there are many if blocks for example that do not ~offer~ folding. Many do, but many don't.

Maybe it's something picked up in my application code over time? Is there a cache or history that needs flushing?

It appears code folding is fundamentally broken and perhaps it's time for a basic design rethink? There are many reports of folding issues and many make sense. Is there a way for all these to be aggregated into a plan to go forward rather than nibbling round the edges?
Comment 4 rmatous 2010-03-18 12:40:56 UTC
-> csl
Comment 5 bhartung 2010-03-20 06:14:53 UTC
Lots of issues here and forum topics for folding, but this title matches my feeling the best.  Even if the item where the entire file collapses is fixed, there is still way to much folding in 6.8.

The folding changes in 6.8 have caused me to go back to 6.7 for now.  If you are going to add more folding than what we used to have, I would like to see checkbox options for us to select what we want folded.  Not what we want folded by default, but folded at all.

I've read all the arguments from the people who wanted if blocks and similar items folded, but it causes tremendous frustration for me because I'm not one to have 1000 line if/else blocks.  The only thing I want folding for are methods and functions.  I know that is an opinion, but that's why I think option boxes to control folding would be best.  Since Netbeans supports so many languages, I don't know if that's better in the General tab or under PHP directly.

Our enterprise is 100% php now and I've almost convinced everyone to use Netbeans, but I can only recommend 6.7 for our coding standards because of this problem.
Comment 6 Vitezslav Stejskal 2010-03-24 09:49:32 UTC
PHP editor adds a 'method' fold for <? ?> blocks. If method folds are collapsed by default then opening a .php file will result with all its content folded. I don't see what's wrong in CSL.
Comment 7 rmatous 2010-03-24 15:10:38 UTC
*** Bug 180690 has been marked as a duplicate of this bug. ***
Comment 8 Quality Engineering 2010-03-25 05:53:20 UTC
Integrated into 'main-golden', will be available in build *201003250201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/51669fc2f64e
User: Radek Matous <rmatous@netbeans.org>
Log: #179462 - Code folding folds too much
Comment 9 rmatous 2010-04-09 15:43:46 UTC
fixed
Comment 10 Filip Zamboj 2010-04-12 11:27:22 UTC
verified in 
Product Version: NetBeans IDE Dev (Build 100412-72e08cda4754)

@reporters: verify your test cases works as expected, please. Don't hesitate to reopen this bug if not. Build with available changeset: 
http://bertram.netbeans.org/hudson/job/PHP-Build/?

thanks.
Comment 11 lathspell 2010-04-15 16:36:06 UTC
I've just tried NetBeans IDE Dev (Build 2010-04-15_15-04-32 ) and found no difference to the behaviour of my original report.

When code folding is enabled with only "[x] methods" checked and I open a .php file containing

<?php

// comment

class {

  function f() {
Comment 12 lathspell 2010-04-15 16:47:37 UTC
(sorry for the unfinished comment above :))

I've just tried NetBeans IDE Dev (Build 2010-04-15_15-04-32 ) and found no
difference to the behaviour of my original report.

When code folding is enabled with only "[x] methods" checked and I open a
test.php
file containing the following snippet I get the following result:

* the outmost "<?php ..." is not folded i.e. "comment 1" visible -> OK (it's
sane)
* the "class C" is folded -> ORIGINAL BUG!
* the "function f" is folded -> OK (desired according to checkbox)

<?php
// comment 1
class C {
  // comment 2
  function f() {
     // comment 3
  }
}

So what exactly has been fixed? In the PHP-build Changes on Hudson I find no
reference to this bug number. I reopen this one, feel free to correct me if I'm wrong.
Comment 13 rmatous 2010-04-21 12:25:15 UTC
http://hg.netbeans.org/web-main/rev/fe6886c219ad

Fixed somehow(class declaration block is treated as "Tag or other code blocks"). 

If you don't like the fix, then reopen and I will consider reverting the fix.

Please be aware that the dialog that you use for tweaking collapse/expand default behavior makes little sense for php. The dialog is implemented for java language not php, so there is no direct mapping between options in dialog and php code blocks, so to achieve proper behavior there is need to have own setting dialog for individual languages and also internally better contract between GsfFoldManager and StrctureScanner implemented for individual languages.

If you feel still unsatisfied with current behavior, then please reopen but then makes sense to change the issue type as ENHANCEMENT and not DEFECT(definitely not defect in php).
Comment 14 Quality Engineering 2010-04-22 04:26:38 UTC
Integrated into 'main-golden', will be available in build *201004220200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/fe6886c219ad
User: Radek Matous <rmatous@netbeans.org>
Log: #179462  -  Code folding folds too much