Bug 448416 - [projection] nested folding is only partially supported
Summary: [projection] nested folding is only partially supported
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-22 15:40 EDT by Bill Fenlason CLA
Modified: 2014-10-23 04:58 EDT (History)
1 user (show)

See Also:


Attachments
modified DefineFoldingRegionAction class from org.eclipse.ui.examples.javaeditor.JavaEditor (1.72 KB, text/plain)
2014-10-22 15:40 EDT, Bill Fenlason CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Fenlason CLA 2014-10-22 15:40:34 EDT
Created attachment 248114 [details]
modified DefineFoldingRegionAction class from org.eclipse.ui.examples.javaeditor.JavaEditor

The current projection / folding support does not deal with (or even consider) multiple folding regions which begin on the same line.  

Using the java editor example (org.eclipse.ui.examples.javaeditor, which in essence simply converts a selected block into a folding region), one can define multiple folding regions which begin on the same line.  When the single annotation is collapsed, one of the regions is apparently randomly selected for the collapse.

From a UI perspective, I think the choice should be to either to disallow the ability to define more than one folding region beginning on the same line, or to provide some visual indication and appropriate actions for collapse and expand.      

It seems to me that a solution for the general case is preferable, such as providing a different color for the annotation, choosing the smallest region to expand/contract first, etc.  Currently, the code apparently ignores multiple folding positions with the same starting point.

Ultimately character based folding rather than line based folding should be designed and implemented, and if so, disallowing multiple folding regions which begin with the same character is more reasonable.

The java editor example does not address this issue.  I have attached a modified version of the DefineFoldingRegionAction class from the example which deletes existing annotations which start on the same line as the newly defined region.  This enhances the demonstrated function by providing a way to delete existing folding regions (selecting the action on a line beginning a folding region but without selecting a block), replace existing regions and requiring new folding regions to be more than one line in length.  If the examples are maintained, perhaps these changes might be useful.

This is surely a duplicate of one or more of the dozens of folding bugs and enhancement requests.