Code Block Remains Visible in Folded Headings

Bug Report: Code Block Remains Visible in Folded Headings After Restart

Summary

In Obsidian, I have a long tutorial (1278 lines) with headings (3 levels deep). When I restart my Mac and open Obsidian, the code block shows up right below the folded heading. However, the code block was initially placed deep inside the heading hierarchy. The expected behavior is to have the code block be hidden when the heading is folded.

Steps to Reproduce

  1. Create a long tutorial in Obsidian with headings up to 3 levels deep.
  2. Insert a code block surrounded by triple backticks deep inside the heading hierarchy.
  3. Fold the headings so that the code block should be hidden.
  4. Restart the Mac and open Obsidian.

Expected Behavior

The code block should remain hidden when the heading is folded.

Observed Behavior

The code block shows up right below the folded heading upon reopening Obsidian after a Mac restart.

Additional Information

  • This issue appears to be specific to code blocks. Regular text, screenshots, or code placed within single backticks do not trigger the issue.
  • I have multiple long tutorials with headings, screenshots, and code blocks surrounded by triple backticks .

Workaround

As a temporary workaround, I have to unfold all headings and fold them up again to hide the code blocks.

Environment

  • Obsidian Version: 1.6.5 (Installer 1.4.13)
  • macOS Version: macOS Sonoma 14.5
  • Device: MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)

Screenshots

Thank you for looking into this issue.

Download and reinstall Obsidian.
Please, Post a screen recording of this happening in the sandbox vault or a new empty vault.

@WhiteNoise Thank you for your swift response!

I performed a clean installation of Obsidian on a Windows 10 machine and synchronized the affected Obsidian vault.

It seems the issue is unrelated to the length of the note/tutorial.

I observed that all affected code blocks in my note begin with a #. It looks like Obsidian is interpreting # inside triple backticks ``` as an H1 heading, thereby elevating the code block to the highest header hierarchy.

Here is an example code block:

# Flush Redis data before starting the Redis service
redis-cli FLUSHALL

Please note that the opening triple backticks are missing in the screenshot.

2024-06-26_165242

Duplicate of