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 +};