diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 5b61c7130..c1f430338 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -92,8 +92,6 @@ const CodeEditor = createClass({ 'Cmd-M' : this.makeSpan, 'Ctrl-/' : this.makeComment, 'Cmd-/' : this.makeComment, - 'Ctrl-\\' : this.toggleCodeFolded, - 'Cmd-\\' : this.toggleCodeFolded, 'Ctrl-[' : this.foldAllCode, 'Cmd-[' : this.foldAllCode, 'Ctrl-]' : this.unfoldAllCode, @@ -171,10 +169,6 @@ const CodeEditor = createClass({ } }, - toggleCodeFolded : function() { - this.codeMirror.foldCode(this.codeMirror.getCursor()); - }, - foldAllCode : function() { this.codeMirror.execCommand('foldAll'); }, diff --git a/shared/naturalcrit/codeEditor/fold-code.js b/shared/naturalcrit/codeEditor/fold-code.js index e43fda8ec..cff1c64e0 100644 --- a/shared/naturalcrit/codeEditor/fold-code.js +++ b/shared/naturalcrit/codeEditor/fold-code.js @@ -6,13 +6,12 @@ module.exports = { if(start.line === cm.firstLine() || prevLine.match(matcher)) { const lastLineNo = cm.lastLine(); - let end = start.line, nextLine = cm.getLine(start.line + 1); + let end = start.line; while (end < lastLineNo) { - if(nextLine.match(matcher)) + if(cm.getLine(end + 1).match(matcher)) break; ++end; - nextLine = cm.getLine(end + 1); } return { @@ -24,4 +23,4 @@ module.exports = { return null; }); } -}; \ No newline at end of file +};