Skip to content

pasting below folded heading hides heading contents #1066

Closed

Description

@JulianBnder

when I have a heading ### example and I paste a line below it ### example /n- [ ] item while it's folded the folding bugs out and it starts to basically ignore the contents until then and only shows the pasted line as the content when folding and unfolding until I tried a couple times and either went up from below with "k" or I clicked on the dots behind the folded heading after clicking something else
(the fact that it unfolds sometimes and sometimes it doesn't when coming across the line from below also seems to be a bug, I feel like it shouldn't unfold)

Activity

  1. adibhanna commented on Nov 9, 2026

    @adibhanna
    Contributor

    Thanks @JulianBnder for the clear report, this one was a real bug and both of the things you noticed came from the same cause.

    What was going on

    A heading's fold starts at the end of the heading line. When text was inserted exactly there, the editor slid the fold past the new text instead of keeping it on the heading. Vim's p for whole lines, o, and Enter all insert the new line at that exact spot, so the pasted lines landed between the heading and its hidden section, and the fold came loose: it hung off the last pasted line and hid the section under it, while the heading itself no longer showed as folded. That is why folding and unfolding then seemed to only toggle the pasted line.

    The fold sometimes opening when you came back up with k was the same loose fold: with the cursor far enough right, k landed on a hidden line at the end of the fold, and the next k stepped into it and opened it.

    The fix

    ZenNotes now treats a closed fold as one line, the way Vim does:

    • p (whole lines) on a folded heading puts the lines below the folded section, and o opens a new line below it. On a folded task, o gives you the next task after its children. P still puts above.
    • With Vim off, Enter at the end of a folded heading opens the new line below the section, and pasting text that starts with a line break does the same.
    • The fold stays on its heading and keeps covering exactly what it covered, and the heading stays marked as folded. Its arrow opens the whole section again.
    • If a paste or Enter splits the folded heading line itself, the fold opens instead of hiding anything.
    • k from below a folded heading now lands on the heading and leaves it closed.

    Only your own typing and pasting is moved; changes coming from disk, workflows or sync land exactly where they were made.

    Fixed in 13d1b66 on the v2.84.0 branch, and it ships in 2.84.0.

    How to test locally

    1. Open a note with:
      ### example
      alpha line
      beta line
      
      ### next
      gamma
      
    2. Vim on: yank two lines with 2yy, move to ### example, fold it with zc, then press p.
      • Before: example loses its fold mark, and the ⋯ follows the pasted lines, hiding alpha line / beta line under them.
      • After: example ⋯ stays folded and the pasted lines show between it and ### next. zo (or the arrow) still opens the original section.
    3. Vim on: with the heading folded, press o and type something. It lands below the folded section.
    4. Vim off: put the caret at the end of the folded ### example and press Enter. The new line opens below the section and the heading stays folded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions