diff --git a/demo/demo.js b/demo/demo.js index 66bc9c6b..f180bfdc 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -21,6 +21,7 @@ * Contributor(s): * Fabian Jakobs * Kevin Dangoor (kdangoor@mozilla.com) + * Julian Viereck * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -154,6 +155,8 @@ exports.launch = function(env) { docs.js.addFold(new Range(1, 10, 2, 10), "foo..."); docs.svg.addFold(new Range(1, 0, 7, 0), "fold..."); + + docs.plain.addFold(new Range(0, 90, 2, 30), "fold"); window.s = docs.js; window.e = env.editor; setTimeout(function() { diff --git a/index.html b/index.html index a4dcc834..7acf756a 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@ diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 151bcc7b..6df87f11 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -1005,30 +1005,38 @@ var EditSession = function(text, mode) { var tokens; var foldLine; - for (var row = firstRow; row <= lastRow; row++) { + var row = firstRow; + while (row <= lastRow) { foldLine = this.getFoldLine(row); if (!foldLine) { tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row])); } else { tokens = []; - foldLine.walk(function(placeholder, row, column, lastColumn) { - var walkTokens; - if (placeholder) { - walkTokens = this.$getDisplayTokens(placeholder, tokens.length); - walkTokens[0] = PLACEHOLDER_START; - for (var i = 1; i < walkTokens.length; i++) { - walkTokens[i] = PLACEHOLDER_BODY; + foldLine.walk( + function(placeholder, row, column, lastColumn) { + var walkTokens; + if (placeholder) { + walkTokens = this.$getDisplayTokens( + placeholder, tokens.length); + walkTokens[0] = PLACEHOLDER_START; + for (var i = 1; i < walkTokens.length; i++) { + walkTokens[i] = PLACEHOLDER_BODY; + } + } else { + walkTokens = this.$getDisplayTokens( + lines[row].substring(lastColumn, column), + tokens.length); } - } else { - walkTokens = this.$getDisplayTokens( - lines[row].substring(lastColumn, column), - tokens.length); - } - tokens = tokens.concat(walkTokens); - }.bind(this), row, lines[row].length); + tokens = tokens.concat(walkTokens); + }.bind(this), + foldLine.end.row, + lines[foldLine.end.row].length + ); } wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); + + row = this.getRowFoldEnd(row) + 1; } }; diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 01b6ca1c..d1d6c3a0 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -501,7 +501,7 @@ var VirtualRenderer = function(container, theme) { }; // For debugging. - // console.log(JSON.stringify(layerConfig)); + console.log(JSON.stringify(layerConfig)); this.$gutterLayer.element.style.marginTop = (-offset) + "px"; this.content.style.marginTop = (-offset) + "px";