From e1697c2dfda2507604ac9674acdd98f71500ec27 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 12 Oct 2012 15:28:02 +0400 Subject: [PATCH] allow folds with empty placeholder --- lib/ace/edit_session.js | 5 ++--- lib/ace/edit_session/folding.js | 7 ++----- lib/ace/edit_session_test.js | 2 +- lib/ace/layer/text.js | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index b23a60ec..09e72ab4 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -1893,10 +1893,9 @@ var EditSession = function(text, mode) { row ++; } else { tokens = []; - foldLine.walk( - function(placeholder, row, column, lastColumn) { + foldLine.walk(function(placeholder, row, column, lastColumn) { var walkTokens; - if (placeholder) { + if (placeholder != null) { walkTokens = this.$getDisplayTokens( placeholder, tokens.length); walkTokens[0] = PLACEHOLDER_START; diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index 7676150c..7b0b929e 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -274,9 +274,6 @@ function Folding() { var endColumn = fold.end.column; // --- Some checking --- - if (fold.placeholder.length < 2) - throw "Placeholder has to be at least 2 characters"; - if (startRow == endRow && endColumn - startColumn < 2) throw "The range has to be at least 2 characters width"; @@ -489,7 +486,7 @@ function Folding() { } lastColumn = Math.max(startColumn, lastColumn); } - if (placeholder) { + if (placeholder != null) { textLine += placeholder; } else { textLine += doc.getLine(row).substring(lastColumn, column); @@ -722,7 +719,7 @@ function Folding() { } else { if (addSubfolds) this.foldAll(row + 1, this.getLength()); - (e.target || e.srcElement).className += " invalid" + (e.target || e.srcElement).className += " ace_invalid" } }; diff --git a/lib/ace/edit_session_test.js b/lib/ace/edit_session_test.js index d349384e..e89ad57f 100644 --- a/lib/ace/edit_session_test.js +++ b/lib/ace/edit_session_test.js @@ -920,7 +920,7 @@ module.exports = { tryAddFold("foo", new Range(0, 13, 0, 18), false); assert.equal(session.$foldData[0].folds.length, 1); - tryAddFold("f", new Range(0, 13, 0, 18), true); + tryAddFold("f", new Range(0, 13, 0, 18), false); tryAddFold("foo", new Range(0, 18, 0, 21), false); assert.equal(session.$foldData[0].folds.length, 2); session.removeFold(fold); diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index c53c7169..812dd066 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -616,7 +616,7 @@ var Text = function(parentEl) { var tokens = session.getTokens(row); foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) { - if (placeholder) { + if (placeholder != null) { renderTokens.push({ type: "fold", value: placeholder