Lists not folding properly when there is a gap in indentation levels when switching from Reading Mode to Live Preview or Source Mode

Steps to reproduce

  1. Open Sandbox Vault
  2. Create a nested list with a structure like this:
- A
	- A1
		- A1.1
		- A1.2
		- A1.3
			- A1.3.1
- B
  1. In Reading Mode, fold “List A1” by clicking its folding arrow
  2. Switch to Live Preview or Source Mode

Did you follow the troubleshooting guide? [Y/N]

Y

Expected result

Only the children lists of “A1” get folded, like this:

- A
	> A1 ...
- B

Actual result

“List B” also gets folded into “A1” accidentally, like this:

- A
	> A1 ...

Environment

SYSTEM INFO:
Obsidian version: v1.8.9
Installer version: v1.8.9
Operating system: Darwin Kernel Version 23.6.0: Thu Dec 19 20:44:10 PST 2024; root:xnu-10063.141.1.703.2~1/RELEASE_ARM64_T6000 23.6.0
Login status: not logged in
Language: en
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

I found the issue occurs when there is a gap in indentation levels between separate lists. In this case:

  • “List A1” (level 1) is followed directly by “List B” (level 0).
  • If I add another list with indentation level 1 called “List A2” above “List B”, like below, everything now folds correctly.
- A
	- A1
		- A1.1
		- A1.2
		- A1.3
			- A1.3.1
	- A2
- B
  • Here’s a screenshot:
    Lists not folding properly when there is a gap in indentation levels when switching from Reading Mode to Live Preview or Source Mode