Bug 56958 - remember code folding state past sessions
Summary: remember code folding state past sessions
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Unclassified
Component: folding (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist with 60 votes (vote)
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 134374 271227 316184 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-04-07 18:52 UTC by Andrea Bergia
Modified: 2014-10-05 16:47 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.0


Attachments
minimal java file (73 bytes, text/x-java)
2014-06-25 11:42 UTC, Phil
Details
minimal php file (80 bytes, application/x-php)
2014-06-25 11:42 UTC, Phil
Details
modified readSession/writeSession functions (code folding state) (2.73 KB, text/x-c++src)
2014-07-01 13:36 UTC, Phil
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrea Bergia 2003-04-07 18:52:52 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.2.2 
OS:          Linux

When I open a file and I play with the code folding, all works well. But if I close the file and I re-open it, all the function that I've "closed" are opened again! I'd like that the status of the document is saved.
Comment 1 Martin Schmitz 2004-06-03 09:44:26 UTC
Hope it's coming soon...

Martin
Comment 2 Dominik Haumann 2006-09-20 17:36:42 UTC
*** Bug 134374 has been marked as a duplicate of this bug. ***
Comment 3 Dominik Haumann 2011-04-19 17:02:44 UTC
*** Bug 271227 has been marked as a duplicate of this bug. ***
Comment 4 Dominik Haumann 2011-07-31 08:59:45 UTC
So the code folding needs load / save routines to serialize and deserialize.
Comment 5 Adrian 2011-08-01 18:37:38 UTC
In progress...
Comment 6 Adrian 2011-08-03 19:04:12 UTC
Git commit f5a86bdda1531d297a0c26ca23779e5a3c2065ad by Adrian Lungu.
Committed on 03/08/2011 at 21:01.
Pushed by lungu into branch 'master'.

BUG: 56958

Automatic folding (remember folding from last sesion) was implemented

M  +10   -1    part/syntax/katecodefolding.h
M  +11   -0    part/document/katedocument.cpp
M  +2    -1    ktexteditor/sessionconfiginterface.h
M  +73   -4    part/syntax/katecodefolding.cpp

http://commits.kde.org/kate/f5a86bdda1531d297a0c26ca23779e5a3c2065ad
Comment 7 Dominik Haumann 2013-08-21 14:45:48 UTC
Again open since KDE 4.11: Implement in KateView::read/writeSessionConfig()
Comment 8 Phil 2014-06-25 11:42:32 UTC
Created attachment 87390 [details]
minimal java file
Comment 9 Phil 2014-06-25 11:42:59 UTC
Created attachment 87391 [details]
minimal php file
Comment 10 Phil 2014-06-25 11:44:07 UTC
remembering code folding from previous session does work for some files (e.g php) and not for some others (e.g java) whereas session file contains correct folding informations for both :

[Document 0]
...
FoldedColumns=0,3
FoldedLines=3,7
...
URL=file:///tmp/file.php


[Document 1]
...
FoldedColumns=0,3
FoldedLines=2,6
...
URL=file:///tmp/file.java
Comment 11 Phil 2014-06-26 09:20:16 UTC
Cannot reproduce this difference java/php today.
Still folding info seems to be saved but not loaded.

Qt: 4.8.6
KDE Development Platform: 4.13.1
Kate: 3.13.1
Comment 12 Phil 2014-06-26 10:42:18 UTC
I made a mistake with the version (I use two different ones)
In latest kate (Qt: 4.8.6/KDE Development Platform: 4.13.1/Kate: 3.13.1) code folding information is NOT stored in the session file.
In an earlier 3.11.3 version of kate, code folding information was stored. But not loaded...
Comment 13 Phil 2014-06-30 16:27:54 UTC
building from the latest source and trying to implement the feature 

looks like "TextFolding" info moved in the session file from [Document] to [Viewspace], must have something to do with http://kate-editor.org/2013/03/27/new-text-folding-in-kate-git-master/

but only commas written here for now as "TextFolding=" info in session file

trying to figure out how to output/input the code folding data : "QVariant(QVariantMap, QMap(("endColumn", QVariant(int, 0) ) ( "endLine" ,  QVariant(int, 56) ) ( "flags" ,  QVariant(int, 2) ) ( "startColumn" ,  QVariant(int, 1) ) ( "startLine" ,  QVariant(int, 46) ) )  )"
Comment 14 Phil 2014-07-01 13:34:40 UTC
data successfully saved/loaded as list "TextFolding=1420,1,1425,1,2" (start line, start column, end line, end column, flags)

code folding state seems functionnal again (maybe more tests needed)

see attachment
Comment 15 Phil 2014-07-01 13:36:36 UTC
Created attachment 87498 [details]
modified readSession/writeSession functions (code folding state)
Comment 16 Dominik Haumann 2014-07-01 15:43:18 UTC
Cool, Phil! Can you post a diff of you patch (git diff on the command line) on reviewboard.kde.org ? This is the standard way to do a review request in KDE/Kate. Thanks!
Comment 17 Phil 2014-07-02 06:51:17 UTC
done
https://git.reviewboard.kde.org/r/119083/
Comment 18 Christoph Cullmann 2014-09-23 18:24:31 UTC
*** Bug 316184 has been marked as a duplicate of this bug. ***
Comment 19 Martin Schmitz 2014-09-24 06:07:55 UTC
...as I wrote Christoph a few years ago: 
For me it would be enough to fold all stuff in the same level using mouse_right or mouse_middle. So a class would look before/after folding:

class foo{
  function foo_1(){
     ...
  }
  function foo_2(){
     ...
  }
  function foo_3(){
     ...
  }
}

class foo{
  function foo_1(){
  function foo_2(){
  function foo_3(){
}

This should not be so hard to program and it would also make files, that never had been opend by kate before, easy to handle.
Comment 20 Dominik Haumann 2014-10-05 16:47:35 UTC
Git commit 390612444dc65f132e6671f564c311fb1e0bf61a by Dominik Haumann.
Committed on 05/10/2014 at 16:45.
Pushed by dhaumann into branch 'master'.

fix: remember code folding state past sessions
REVIEW: 120436
FIXED-IN: 5.0

M  +1    -1    autotests/src/katetextbuffertest.cpp
M  +0    -117  autotests/src/kateview_test.cpp
M  +0    -5    autotests/src/kateview_test.h
M  +12   -8    src/buffer/katetextfolding.cpp
M  +7    -5    src/buffer/katetextfolding.h
M  +8    -8    src/view/kateview.cpp
M  +1    -1    src/view/kateview.h

http://commits.kde.org/ktexteditor/390612444dc65f132e6671f564c311fb1e0bf61a