Skip to content

Commit

Permalink
Don't fold list nodes
Browse files Browse the repository at this point in the history
FIX: Disable folding for list nodes (since it will shadow the folding on the first
list item).

See https://discuss.codemirror.net/t/interesting-list-folding-behavior/8021/3
  • Loading branch information
marijnh committed Mar 24, 2024
1 parent 54a4448 commit 3d6fd9d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/markdown.ts
Expand Up @@ -10,7 +10,7 @@ const headingProp = new NodeProp<number>()
const commonmark = baseParser.configure({
props: [
foldNodeProp.add(type => {
return !type.is("Block") || type.is("Document") || isHeading(type) != null ? undefined
return !type.is("Block") || type.is("Document") || isHeading(type) != null || isList(type) ? undefined
: (tree, state) => ({from: state.doc.lineAt(tree.from).to, to: tree.to})
}),
headingProp.add(isHeading),
Expand All @@ -28,6 +28,10 @@ function isHeading(type: NodeType) {
return match ? +match[1] : undefined
}

function isList(type: NodeType) {
return type.name == "OrderedList" || type.name == "BulletList"
}

function findSectionEnd(headerNode: SyntaxNode, level: number) {
let last = headerNode
for (;;) {
Expand Down

0 comments on commit 3d6fd9d

Please sign in to comment.