New Text Folding in kate.git master

In the kate.git master branch the text folding is now new and shiny.

In addition to be faster and less memory hungry (no folding tree is around if you fold nothing, it is only created on-demand exactly for the folded regions), the new code is less complex and smaller (and hopefully better documented + unit tested, it actually has a test for most internal operations).

There is actually now a clean separation, the folding does not mix with highlighting and can be used without it, too.

This allows for a better integration of indentation based foldings like in Python (and already fixes the most ugly miss-placements of folding regions there) and empowers the user to fold arbitrary regions manually.

This can be done at the moment with two kate commands (for the F7 command line):

  • “fold” will create persistent fold for the current selection, this fold will stay until next reload of document (will implement some dfold command later, to delete it)
  • “tfold” will create temporary fold for the current selection, this fold will disappear again on unfolding

This should allow better vi mode integration, too, as vi is able to fold arbitrary regions, too. (There is an internal API to fold any KTextEditor::Range you pass in, which should allow to fold by regex and other ways, too, if somebody steps up to implement it.)

If you find glitches, please report them as bugs and please attach some file to reproduce, I am very interested to get this all in even better shape for KDE 4.11, be folding crashs a thing of the past.

P.S.

For all people not using folding at all, be happy, it no longer will crash you (and me), as it is a nop if no folding ranges are created by the user and some extreme cases got a speedup of 1000% because of less overhead, like VERY large C++ sources ;)

4 thoughts on “New Text Folding in kate.git master”

  1. Great ! And by the way, I just love the new mini-map but I didn’t know where to say it :-)
    Thank you to the kate team

  2. Shame Kate still won’t remember folding states for remote files (opened via Dolphin and ssh/ftp network folders). I had it done via sshfs (and disabled Kate’s .swp files to speed things up), but after update to Kubuntu 13.04 sshfs messes up owners/groups for me, and despite various attempts I can’t get it going.

    So I’m back to network folders and manual folding of every file I open before editing it (which makes me wonder why I’m not using Notepad++ on Windows/Wine).

  3. You mention better vi mode integration with code folding. Will we eventually be able to use vim’s code folding shortcuts (e.g. zo, zc, za and zx in normal mode)? This would make me very happy. :-)

Leave a Reply