When folding, don't include trailing empty lines


  1. Add a title with “# Title A” then a subtitle with “## Subtitle” and then again any title with “# Title B”
  2. Add some content below of each of the titles
  3. Fold the subtitle

You will then see, that subtitle and the next title will have no gap between them, which makes reading a bit difficult.

If you add a newline before “# Title B” you now have a fitting gap.

So far so good.

But now expand and fold the subtitle again!

You will see that the subtitle “ate” the new empty line!
Will leads in the subtitle growing over time with more and more empty lines and you never will have the distance between the titles.

Proposed Solution

For folding, only fold up to the last line with content, but NOT empty lines!

Trailing empty times should never be folded - they don’t belong to the folded section but to the containing file itself.


Did not yet get much attention :slight_smile:

But I think it is obvious … probably, I could not make my point clear enough.

Any section should END with the last line of content!

This seems logical, but it is not currently true in the implementation.

It should be fixed easily.

I retitled the thread to emphasize the request rather than the problem. (Was “Folding does fold too much - including trailing empty lines”.)

1 Like

That does not remove the problem, or?

The previous title stated the problem that the requested feature would solve. The new title describes the feature itself.

If you mean this doesn’t solve the problem, that’s true.

1 Like

Here is a screenshot highlighting the issue:

Without folding the content looks as follows:

An empty line after the folded heading would make the fold look better. Currently it hangs ontop the following heading.

1 Like