mirror of
https://github.com/wassname/jupyter_contrib_nbextensions.git
synced 2026-08-11 11:19:52 +08:00
bugfix in nbextensions/usability/codefolding - fix dependency race condition with a require call.
This commit is contained in:
@@ -5,10 +5,10 @@ CodeMirror.registerHelper("fold", "firstline", function(cm, start) {
|
||||
var lineText = cm.getLine(start.line);
|
||||
var found = lineText.lastIndexOf(Token,0);
|
||||
if (found == 0) {
|
||||
end = cm.lastLine();
|
||||
end = cm.lastLine();
|
||||
return {from: CodeMirror.Pos(start.line, null),
|
||||
to: CodeMirror.Pos(end, null)};
|
||||
to: CodeMirror.Pos(end, null)};
|
||||
}
|
||||
}
|
||||
return ;
|
||||
return ;
|
||||
});
|
||||
|
||||
@@ -118,10 +118,10 @@ define([
|
||||
var found = jQuery.inArray("CodeMirror-foldgutter", gutters);
|
||||
if ( found == -1) {
|
||||
cell.code_mirror.setOption('gutters', [ gutters , "CodeMirror-foldgutter"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add codefolding gutter to a new cell
|
||||
*
|
||||
@@ -162,7 +162,7 @@ define([
|
||||
break;
|
||||
}
|
||||
cell.code_mirror.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
cell.code_mirror.on('fold',updateMetadata);
|
||||
cell.code_mirror.on('unfold',updateMetadata);
|
||||
@@ -183,19 +183,19 @@ define([
|
||||
link.rel = "stylesheet";
|
||||
link.href = require.toUrl(name, 'css');
|
||||
document.getElementsByTagName("head")[0].appendChild(link);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize extension
|
||||
*
|
||||
*/
|
||||
var load_extension = function() {
|
||||
var load_extension = function() {
|
||||
load_css('codemirror/addon/fold/foldgutter.css');
|
||||
/* change default gutter width */
|
||||
load_css( './foldgutter.css');
|
||||
/* additional custom codefolding mode */
|
||||
require(['./firstline-fold']);
|
||||
setTimeout(initGutter, 100)
|
||||
/* require our additional custom codefolding modes before initialising
|
||||
fully */
|
||||
require(['./firstline-fold', './magic-fold'], initGutter);
|
||||
};
|
||||
|
||||
return {load_ipython_extension : load_extension};
|
||||
|
||||
Reference in New Issue
Block a user