Bug 318595

Summary: No code folding with beginRegion and endRegion
Product: [Applications] kate Reporter: Russell <prusselltechgroup>
Component: foldingAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: christoph, ilmari.lauhakangas, walch.martin
Priority: NOR    
Version: 16.04.1   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: tar file that contains multiple files described in the above bug report
Code folding in 4.13 vs 3.3.5 - end region
Missing Unfold Toplevel Nodes (previously vs Kate Ver 4.14.3)

Description Russell 2013-04-19 15:33:19 UTC
Code Folding in Kate 3.10.0,  no longer folds regions that begin and end with the same identifier.  
For example:

 beginRegion="aRegion" endRegion="aRegion"

It worked nicely in Kate 3.3.5 and 3.7.2.

Attached files:
1) kate-codefolding-unfolded.png - Shows how code folding appears unfolded on  all versions of Kate mentioned above.

2) kate-3.7.2-codefolding-folded.png - Shows how code folding appears folded on 3.3.5 and 3.7.2.

3) kate-3.10.0-codefolding-folded.png - Shows how code folding appears folded on 3.10.0

4) katecodefoldingtest.txt - Sample text file used in images above.

5) katecodefoldingtest.xml - Sample Kate syntax file used in this test.

6) setup.sh - For your convenience, a Bash script to setup and test using the above xml and txt files. It basically adds/removes a symbolic link in "$(kde4-config --localprefix)share/apps/katepart/syntax/" and optionally  starts Kate with the above txt file.


Reproducible: Always

Steps to Reproduce:
1. Use the katecodefoldingtest.xml file in the attachment. It is a shortened version that specifically demonstrates the problem.
2. Start kate. Open the attached sample file.
3. View -> Code Folding -> Fold Toplevel Nodes
Actual Results:  
Everything folded into one level.



Expected Results:  
Expected to see similar results as in Kate 3.3.5 and 3.7.2, which folded each region.

Please see attachment.
Comment 1 Russell 2013-04-19 15:35:04 UTC
Created attachment 79028 [details]
tar file that contains multiple files described in the above bug report
Comment 2 Martin Walch 2014-05-13 01:22:29 UTC
I just tested this in Kate 4.13.0. Seems to work fine again. There is only one difference  when comparing against the behaviour of 3.7.2:  the line

// kate: syntax KateCodeFoldingTest; folding-markers on;

stays visible below "=== Simple Commands ===" (Which might be intended?)

Do you still experience the problem?
Comment 3 Russell 2014-05-13 08:46:41 UTC
Code folding is definitely producing similar results as in Kate 3.3.5 and 3.7.2, with the exception noted, plus a missing "Expand TopLevel" menu item.

It does not appear to be isolated to  katecodefoldingtest.txt and katecodefoldingtest.xml. 
I opened up the bash script, setup.sh,  hovered over the code regions to see how far they stretched and also clicked "Collapse Toplevel". I got different results.  Kate 4.13 does not include the end region in the fold, while previous versions did.  For example:

Kate 4.13:   if....
                    fi
Kate 3.3.5:  if...

The other item I noticed, there is no "Expand Toplevel" menu item. I have "Collapse Toplevel" and "Expand Toplevel" icons on Kate's Main Toolbar <KatePartView>.  Click "Collapse Toplevel" and there's the highlevel structure of the document. And when done, click "Expand Toplevel". I only saw "Collapse Toplevel" in Kate 4.13, I did not see "Expand Toplevel".
Comment 4 Russell 2014-05-13 09:12:10 UTC
Created attachment 86605 [details]
Code folding in 4.13 vs 3.3.5 - end region
Comment 5 Russell 2014-12-12 11:49:04 UTC
Created attachment 89937 [details]
Missing Unfold Toplevel Nodes (previously vs Kate Ver 4.14.3)

The actually code folding is working.  
Current environment openSUSE 13.2, Kate 4.13.3.

But "unfold toplevel nodes" is missing.

The keyboard shortcuts are ctrl+shift+- (FOLD) and ctrl+shift++ (UNFOLD).  
They are a toggle to fold and unfold the document.
I also put toolbar buttons on the Main Toolbar <KatePartView> for these functions.
Comment 6 Buovjaga 2016-06-21 17:29:09 UTC
(In reply to prusselltechgroup from comment #5)
> But "unfold toplevel nodes" is missing.

Still missing in the view menu.

Arch Linux 64-bit
Kate 16.04.2
KDE Frameworks 5.22.0
Qt 5.6.1
xcb wm
Comment 7 Buovjaga 2016-06-25 16:22:35 UTC
> (In reply to prusselltechgroup from comment #5)
> But "unfold toplevel nodes" is missing.

This is reported as bug 335590
Comment 8 Christoph Cullmann 2016-09-07 13:38:21 UTC
The missing menu item is still a "problem", therefore we have bug 335590, otherwise, the folding in KF5 based KTextEditor should be "OK".