Skip to content

Commit d68db0e

Browse files
committed
Run blocking
1 parent 0cc9046 commit d68db0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/DocumentView/CodeBlock/highlight.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type InlineIndexed = { inline: any; start: number; end: number };
3030
type PositionedToken = ThemedToken & { start: number; end: number };
3131

3232
let lineCount = 0;
33-
34-
const LINE_LIMIT = 500;
33+
const LINE_LIMIT = 1000;
34+
const renderer = asyncMutexFunction();
3535

3636
/**
3737
* Highlight a code block while preserving inline elements.
@@ -60,10 +60,10 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
6060
const highlighter = await loadHighlighter();
6161
await loadHighlighterLanguage(highlighter, langName);
6262

63-
const lines = highlighter.codeToTokensBase(code, {
63+
const lines = await renderer.runBlocking(async () => highlighter.codeToTokensBase(code, {
6464
lang: langName,
6565
tokenizeMaxLineLength: 120,
66-
});
66+
}));
6767

6868
console.log(
6969
`${block.key} lines:${lineCount} block has ${

0 commit comments

Comments
 (0)