Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
emmerich committed Apr 13, 2024
1 parent 339bd41 commit 8c0fb8a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/components/DocumentView/CodeBlock/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ type InlineIndexed = { inline: any; start: number; end: number };

type PositionedToken = ThemedToken & { start: number; end: number };

const renderer = asyncMutexFunction();
let blockCount = 0;
let lineCount = 0;

const LINE_LIMIT = 1000;
Expand All @@ -46,13 +44,9 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
return plainHighlighting(block);
}

const overLimit = await renderer.runBlocking(async () => {
lineCount += block.nodes.length;
blockCount++;
return lineCount > LINE_LIMIT;
})

if (overLimit) {
lineCount += block.nodes.length;
console.log(`highlight, lineCount ${lineCount}`);
if (lineCount > LINE_LIMIT) {
return plainHighlighting(block);
}

Expand All @@ -72,7 +66,7 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
});

console.log(
`${block.key} ${JSON.stringify({ blockCount, lineCount })} block has ${
`${block.key} lines:${lineCount} block has ${
block.nodes.length
} lines, ${code.length} characters ${inlines.length} inlines`,
);
Expand Down

0 comments on commit 8c0fb8a

Please sign in to comment.