fix: Code blocks nested in list do not get line numbers

This commit is contained in:
Tom Moor
2023-08-15 19:52:16 +02:00
parent 8bff566c30
commit 0047384d70
2 changed files with 7 additions and 5 deletions

View File

@@ -74,9 +74,10 @@ function getDecorations({
lineNumbers?: boolean;
}) {
const decorations: Decoration[] = [];
const blocks: { node: Node; pos: number }[] = findBlockNodes(doc).filter(
(item) => item.node.type.name === name
);
const blocks: { node: Node; pos: number }[] = findBlockNodes(
doc,
true
).filter((item) => item.node.type.name === name);
function parseNodes(
nodes: refractor.RefractorNode[],

View File

@@ -50,8 +50,9 @@ export function findChildren(
* are blocks.
*
* @param node The node to iterate over
* @param descend Whether to descend into a node
* @returns Child nodes that are blocks
*/
export function findBlockNodes(node: Node): NodeWithPos[] {
return findChildren(node, (child) => child.isBlock);
export function findBlockNodes(node: Node, descend = false): NodeWithPos[] {
return findChildren(node, (child) => child.isBlock, descend);
}