allow folds with empty placeholder

This commit is contained in:
nightwing 2012-10-12 15:28:02 +04:00
commit e1697c2dfd
4 changed files with 6 additions and 10 deletions

View file

@ -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;

View file

@ -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"
}
};

View file

@ -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);

View file

@ -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