File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
src/components/DocumentView/CodeBlock Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -46,10 +46,13 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
46
46
return plainHighlighting ( block ) ;
47
47
}
48
48
49
- lineCount += block . nodes . length ;
50
- blockCount ++ ;
49
+ const overLimit = await renderer . runBlocking ( async ( ) => {
50
+ lineCount += block . nodes . length ;
51
+ blockCount ++ ;
52
+ return lineCount > LINE_LIMIT ;
53
+ } )
51
54
52
- if ( lineCount > LINE_LIMIT ) {
55
+ if ( overLimit ) {
53
56
return plainHighlighting ( block ) ;
54
57
}
55
58
@@ -60,14 +63,12 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
60
63
return a . start - b . start ;
61
64
} ) ;
62
65
63
- const lines = await renderer . runBlocking ( async ( ) => {
64
- const highlighter = await loadHighlighter ( ) ;
65
- await loadHighlighterLanguage ( highlighter , langName ) ;
66
+ const highlighter = await loadHighlighter ( ) ;
67
+ await loadHighlighterLanguage ( highlighter , langName ) ;
66
68
67
- return highlighter . codeToTokensBase ( code , {
68
- lang : langName ,
69
- tokenizeMaxLineLength : 120 ,
70
- } ) ;
69
+ const lines = highlighter . codeToTokensBase ( code , {
70
+ lang : langName ,
71
+ tokenizeMaxLineLength : 120 ,
71
72
} ) ;
72
73
73
74
console . log (
You can’t perform that action at this time.
0 commit comments