Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#285 IndentFoldHandler - allow blank lines after start of fold

Suraj Kurapati

This patch considers blank lines that come after the start of a fold as part of the fold itself. This was a major annoyance for me for many years and I am finally glad to have fixed it! :-)

Attached are two screencasts demonstrating the before & after of applying this patch.

Thanks for your consideration.


  • Suraj Kurapati
    Suraj Kurapati

    • labels: --> texteditor
  • Your patch works as you expect it to, but I don't see the point. Why not just regard whitespace-only lines the same as other lines? It's indent-fold-handler - which means it should set fold levels according to indentation.

  • Suraj Kurapati
    Suraj Kurapati

    Correct, but a line containing only whitespace has no meaning in any programming languages (except the "Whitespace" language, but nobody uses that! http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29\). Such lines should be ignored in fold level processing --- they should neither increase nor decrease the current fold level.

    Here is my use case: I like to use indentation-based folding & code-comments to manage the complexity of my code, and I like to add at least one blank line after a "fold comment" to make the code readable in non-folding editors:

    // this is a fold comment
    <blank line>
    <indentation>code described by the fold comment

    Without this patch, I was always forced (for 5 years now!) to remove the blank line after the "fold comment" and it makes my code look very ugly. Furthermore, you will notice in the "before screencast" how blank lines after a "fold comment" break the fold guides (the vertical lines denoting each indentation level).

    Is this more clear? Thanks for your consideration.

  • Suraj Kurapati
    Suraj Kurapati

    Also, this patch isn't perfect because I'm not an experienced jEdit developer. I just came upon the solution through trial and error. If you could suggest a more efficient way to implement this, I would be very greatful. Thanks for your consideration.

  • I just realized that whitespace-only lines may not preserve the amount of whitespace used by the indentation of actual source lines. Even though jEdit initially indents them as it would indent any source code line, you can delete some of these whitespace characters or add to them, with no visible effect, breaking the fold handler.
    So, your patch makes sense.
    I will see what I can do about the performance.

  • Committed a modified version of this patch to SVN rev. 16129.
    The modified version is identical in functionality, it just replaces the recursion with a flat loop.

    • assigned_to: nobody --> shlomy
    • status: open --> closed-accepted