diff --git a/usability/codefolding/codefolding.js b/usability/codefolding/codefolding.js index c81b63e..4144a23 100644 --- a/usability/codefolding/codefolding.js +++ b/usability/codefolding/codefolding.js @@ -1,14 +1,18 @@ // Allow codefolding in code cells -var codefolding_extension = (function() { +define([ + 'require', + 'components/codemirror/addon/fold/foldgutter', + 'components/codemirror/addon/fold/foldcode', + 'components/codemirror/addon/fold/brace-fold', + 'components/codemirror/addon/fold/indent-fold' +], function(require) { "use strict"; if (IPython.version[0] != 2) { console.log("This extension requires IPython 2.x") return } - var hotKey = "Alt-F"; - function toggleFolding(cm) { var pos = cm.getCursor(); var opts = cm.state.foldGutter.options; @@ -26,7 +30,7 @@ var codefolding_extension = (function() { var ret = {}; var len = arguments.length; for (var i=0; i myIndent) { - // Lines with a greater indent are considered part of the block. - lastLineInFold = i; - } else if (!/\S/.test(curLine)) { - // Empty lines might be breaks within the block we're trying to fold. - } else { - // A non-empty line at an indent equal to or less than ours marks the - // start of another block. - break; - } - } - if (lastLineInFold) return { - from: CodeMirror.Pos(start.line, firstLine.length), - to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length) - }; -}); -CodeMirror.indentRangeFinder = CodeMirror.fold.indent; // deprecated