Skip to content

[enhancement] improve code folding#6115

Merged
nathanlesage merged 6 commits into
Zettlr:developfrom
benniekiss:folding
Jan 10, 2026
Merged

[enhancement] improve code folding#6115
nathanlesage merged 6 commits into
Zettlr:developfrom
benniekiss:folding

Conversation

@benniekiss

Copy link
Copy Markdown
Collaborator

Description

This PR adds code folding to YAML and PandocDiv nodes, and it preserves folded regions across editor focus changes

Changes

A foldNodeProp was added to the markdown parser, which calculates fold regions for pandoc divs and yaml frontmatter.

A foldedRanges attribute was added to EditorViewPersistentState, which holds a decoration set of the currently folded ranges in the editor. When the document is loaded, the range set is iterated over, and a fold effect is dispatched for each range. This preserves the folded ranges across editor focus changes.

The styling for the foldPlaceholder was moved to the main-overrides file, and the background was made transparent. Previously, the background color was set to match the old editor background color, but that was updated in v4, and now the fold placeholder is out-of-sync. Making it transparent removes the need to keep it in sync. A border element was added to the dark mode placeholder, and this matches the light mode styling.

Additional information

Tested on: macOS 26/Fedora 43

@nathanlesage

Copy link
Copy Markdown
Member

This appears to fix #3241.

@nathanlesage nathanlesage linked an issue Jan 10, 2026 that may be closed by this pull request
3 tasks
@nathanlesage nathanlesage merged commit 5b0dad9 into Zettlr:develop Jan 10, 2026
1 check passed
@benniekiss benniekiss deleted the folding branch January 10, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Remember collapsed title

2 participants