File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 135135 const codePre = document . getElementById ( 'code-pre' ) ;
136136 if ( cmWrap && codePre ) {
137137 const code = codePre . textContent . trim ( ) ;
138- CodeMirror ( cmWrap , {
139- value : code ,
138+ const cm = CodeMirror ( cmWrap , {
139+ value : '' ,
140140 mode : 'cppmode' ,
141141 theme : dark ? 'cppmode-dark' : 'cppmode' ,
142142 readOnly : true ,
143143 lineNumbers : true ,
144144 lineWrapping : false ,
145145 } ) ;
146+ // Set value after init so CPPMODE_KEYWORDS is definitely loaded
147+ setTimeout ( ( ) => { cm . setValue ( code ) ; cm . refresh ( ) ; } , 0 ) ;
146148 }
147149 // Reference pages: replace .syntax-block and .impl-block
148150 document . querySelectorAll ( '.syntax-block, .impl-block' ) . forEach ( el => {
152154 if ( ! code ) return ;
153155 const wrap = document . createElement ( 'div' ) ;
154156 el . parentNode . replaceChild ( wrap , el ) ;
155- CodeMirror ( wrap , {
156- value : code ,
157+ const cm2 = CodeMirror ( wrap , {
158+ value : '' ,
157159 mode : 'cppmode' ,
158160 theme : dark ? 'cppmode-dark' : 'cppmode' ,
159161 readOnly : true ,
160162 lineNumbers : false ,
161163 lineWrapping : false ,
162164 } ) ;
165+ setTimeout ( ( ) => { cm2 . setValue ( code ) ; cm2 . refresh ( ) ; } , 0 ) ;
163166 } ) ;
164167 } ) ;
165168 } ) ;
You can’t perform that action at this time.
0 commit comments