@@ -27,6 +27,7 @@ define([
27
27
// define default config parameter values
28
28
var params = {
29
29
codefolding_hotkey : 'Alt-f' ,
30
+ init_delay : 1000
30
31
} ;
31
32
32
33
// updates default params with any specified in the provided config data
@@ -109,12 +110,12 @@ define([
109
110
}
110
111
/* User can click on gutter of unselected cells, so make sure we store metadata in the correct cell */
111
112
var cell = Jupyter . notebook . get_selected_cell ( ) ;
112
- if ( cell . code_mirror != cm ) {
113
+ if ( cell . code_mirror !== cm ) {
113
114
var cells = Jupyter . notebook . get_cells ( ) ;
114
115
var ncells = Jupyter . notebook . ncells ( ) ;
115
116
for ( var k = 0 ; k < ncells ; k ++ ) {
116
117
var _cell = cells [ k ] ;
117
- if ( _cell . code_mirror == cm ) { cell = _cell ; break ; }
118
+ if ( _cell . code_mirror === cm ) { cell = _cell ; break ; }
118
119
}
119
120
}
120
121
cell . metadata . code_folding = lines ;
@@ -123,12 +124,12 @@ define([
123
124
/**
124
125
* Activate codefolding in CodeMirror options, don't overwrite other settings
125
126
*
126
- * @param cell {codecell.CodeCell} code cell to activate folding gutter
127
+ * @param cm codemirror instance
127
128
*/
128
129
function activate_cm_folding ( cm ) {
129
130
var gutters = cm . getOption ( 'gutters' ) . slice ( ) ;
130
131
if ( $ . inArray ( "CodeMirror-foldgutter" , gutters ) < 0 ) {
131
- gutters . push ( 'CodeMirror-foldgutter' )
132
+ gutters . push ( 'CodeMirror-foldgutter' ) ;
132
133
cm . setOption ( 'gutters' , gutters ) ;
133
134
}
134
135
@@ -242,7 +243,10 @@ define([
242
243
/* require our additional custom codefolding modes before initialising fully */
243
244
require ( [ './firstline-fold' , './magic-fold' ] , function ( ) {
244
245
if ( Jupyter . notebook . _fully_loaded ) {
245
- initExistingCells ( ) ;
246
+ setTimeout ( function ( ) {
247
+ console . log ( 'Codefolding: Wait for' , params . init_delay , 'ms' ) ;
248
+ initExistingCells ( ) ;
249
+ } , params . init_delay ) ;
246
250
}
247
251
else {
248
252
events . one ( 'notebook_loaded.Notebook' , initExistingCells ) ;
@@ -252,8 +256,9 @@ define([
252
256
else {
253
257
activate_cm_folding ( Jupyter . editor . codemirror ) ;
254
258
setTimeout ( function ( ) {
259
+ console . log ( 'Codefolding: Wait for' , params . init_delay , 'ms' ) ;
255
260
Jupyter . editor . codemirror . refresh ( ) ;
256
- } , 1000 ) ;
261
+ } , params . init_delay ) ;
257
262
}
258
263
} ;
259
264
0 commit comments