Skip to content

Commit

Permalink
Run blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
emmerich committed Apr 13, 2024
1 parent 0cc9046 commit d68db0e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/DocumentView/CodeBlock/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type InlineIndexed = { inline: any; start: number; end: number };
type PositionedToken = ThemedToken & { start: number; end: number };

let lineCount = 0;

const LINE_LIMIT = 500;
const LINE_LIMIT = 1000;
const renderer = asyncMutexFunction();

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

const lines = highlighter.codeToTokensBase(code, {
const lines = await renderer.runBlocking(async () => highlighter.codeToTokensBase(code, {
lang: langName,
tokenizeMaxLineLength: 120,
});
}));

console.log(
`${block.key} lines:${lineCount} block has ${
Expand Down

0 comments on commit d68db0e

Please sign in to comment.