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 89955 - Multiple folds on the same line problem
Summary: Multiple folds on the same line problem
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Code folding (show other bugs)
Version: 6.x
Hardware: PC All
: P4 blocker (vote)
Assignee: mslama
URL:
Keywords:
: 75273 144385 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-11-23 14:51 UTC by Jiri Prox
Modified: 2009-06-12 15:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screenshot (5.85 KB, image/png)
2006-11-23 14:51 UTC, Jiri Prox
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2006-11-23 14:51:18 UTC
NetBeans IDE Dev (Build 20061120-0828)
1.6.0-rc; Java HotSpot(TM) Client VM 1.6.0-rc-b104
Windows XP version 5.1 running on x86
en_US (nb); Cp1252


Code folding is broken when new method is added to the file where is extra '}'
at the end. 

Steps to reproduce:
1) have class:
public class Test {
    
    public void method1() 
    
    public void method2() {
        
   }    
}
}
2) type '{' behind the head of method method1 and press enter
-> closing '}' is not added
-> fold is created w/o marked end
3) collapse the 1st fold
-> it cannot be unfolded, while clicking on 'plus' symbol will collapse/expand
the 2nd fold, 1st is still folded
Comment 1 Jiri Prox 2006-11-23 14:51:52 UTC
Created attachment 36248 [details]
screenshot
Comment 2 Vitezslav Stejskal 2007-03-20 02:53:07 UTC
Yeah, this is broken. I am not familiar with the code folding implementation,
but could not we simply assume that if FoldManager provides two overlapping
folds at *the same* level the first one ends where the second one begins. There
is no point in having overlapping folds anyway. FoldManagers should not be
allowed to return overlapping folds and if they do it means that something is
broken with that FoldManager. The infrastructure should detect this situation
and handle it gracefully.
Comment 3 Miloslav Metelka 2007-03-20 17:52:41 UTC
Any fold can be unfolded by double-clicking on it including this case.
The fold hierarchy checks for overlapping folds and does not permit them. But in
this case the folds are not overlapping - the java infrastructure ends the first
fold before the declaration of the method that follows. You can verify it if you
go to navigator and select "Trees" view.

So the only thing that could IMHO be improved on the editor side is that the
click on "+" for collapsed folds would uncollapse *all* the collapsed folds
present on the given visual line. Is that desirable?
Comment 4 Vitezslav Stejskal 2007-03-21 00:32:24 UTC
I see, multiple folds on the same line are quite tricky to handle. You don't
need broken java code, the same problem happens for example in this situation:

public void a() {
} public void b() {
}

or

<tag>
</tag><tag>
</tag>

I think that [-]/[+] should collapse/expand *all* folds that are defined on the
line, which the fold handle was created for. It would be more predictable
behavior. I for example didn't know that clicking a folded fold expands it.

How do eclipse or idea deal with this situation?
Comment 5 Miloslav Metelka 2007-03-21 17:19:40 UTC
Idea behaves exactly like we do incl. inability to expand the first fold and the
double-click to expand :)
Ecl. hides the whole line where a fold ends so it's strange as when folding the
first method the next method's header disappears completely.
Comment 6 Vitezslav Stejskal 2007-03-21 22:20:09 UTC
So, we are not doing that bad afterall. :)
Comment 7 Vitezslav Stejskal 2007-04-16 03:43:39 UTC
*** Issue 75273 has been marked as a duplicate of this issue. ***
Comment 8 Jiri Prox 2008-02-22 15:07:24 UTC
Fold can be expanded as was said -> so it's not so serious problem
Comment 9 Jiri Prox 2008-04-11 00:42:40 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 10 Petr Dvorak 2008-08-19 16:09:07 UTC
*** Issue 144385 has been marked as a duplicate of this issue. ***
Comment 11 David Strupl 2009-06-08 14:11:56 UTC
Marek, these are yours now ...
Comment 12 mslama 2009-06-12 15:30:17 UTC
The first use case is incorrect uncompilable code. We can support correct code ie. IMO WONTFIX.

Second case from Vita when first fold ends on the same line where second starts work fine now even if there is no
fold/unfold button/annotation for second fold. It is possible to unfold second fold by double click on folded box of
second fold. Definitely it is better to avoid such situation.