Markdown code snippets with a heading breaks native-heading folding

Steps to reproduce

This can be reproduced in the sandbox in a new page with the following content:

Headline 1

Headline 2

# snippet Headline #1

Note that this appears to fold up to the L1 header in the snippet when not in reading mode. Operating in reading mode appears to fold all content correctly on my attempt.

Did you follow the troubleshooting guide?


Expected result

All appropriate content in section under the header is folded up, independent of the markdown content in the snippet.

Actual result

Content under the header is folded up dependent on the content of the snippet, eg. if you are folding a header at the same level or that is a subheader to a header written in the markdown code snippet, you will fold up to the header in the code snippet. This leaves the codeblock half-rendered.


Obsidian version: v1.5.12
Installer version: v1.5.8
Operating system: #1 SMP PREEMPT_DYNAMIC Debian 6.6.15-2###2 (2024-03-19) 6.6.15-2###2-amd64
Login status: not logged in
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on


Note: I run a corporate linux distribution based on debian and have redacted internal codenames above with ###. This should be somewhat equivalent to Debian testing. This is also operating under a Chrome OS Linux VM through the system-provided integration, though, ideally, this shouldn’t make a difference…

Additional information

See these screenshots:
Screenshot 2024-05-03 14.03.52

Screenshot 2024-05-03 14.04.17

Folded (reading view):