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 ++; row ++;
} else { } else {
tokens = []; tokens = [];
foldLine.walk( foldLine.walk(function(placeholder, row, column, lastColumn) {
function(placeholder, row, column, lastColumn) {
var walkTokens; var walkTokens;
if (placeholder) { if (placeholder != null) {
walkTokens = this.$getDisplayTokens( walkTokens = this.$getDisplayTokens(
placeholder, tokens.length); placeholder, tokens.length);
walkTokens[0] = PLACEHOLDER_START; walkTokens[0] = PLACEHOLDER_START;

View file

@ -274,9 +274,6 @@ function Folding() {
var endColumn = fold.end.column; var endColumn = fold.end.column;
// --- Some checking --- // --- Some checking ---
if (fold.placeholder.length < 2)
throw "Placeholder has to be at least 2 characters";
if (startRow == endRow && endColumn - startColumn < 2) if (startRow == endRow && endColumn - startColumn < 2)
throw "The range has to be at least 2 characters width"; throw "The range has to be at least 2 characters width";
@ -489,7 +486,7 @@ function Folding() {
} }
lastColumn = Math.max(startColumn, lastColumn); lastColumn = Math.max(startColumn, lastColumn);
} }
if (placeholder) { if (placeholder != null) {
textLine += placeholder; textLine += placeholder;
} else { } else {
textLine += doc.getLine(row).substring(lastColumn, column); textLine += doc.getLine(row).substring(lastColumn, column);
@ -722,7 +719,7 @@ function Folding() {
} else { } else {
if (addSubfolds) if (addSubfolds)
this.foldAll(row + 1, this.getLength()); 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); tryAddFold("foo", new Range(0, 13, 0, 18), false);
assert.equal(session.$foldData[0].folds.length, 1); 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); tryAddFold("foo", new Range(0, 18, 0, 21), false);
assert.equal(session.$foldData[0].folds.length, 2); assert.equal(session.$foldData[0].folds.length, 2);
session.removeFold(fold); session.removeFold(fold);

View file

@ -616,7 +616,7 @@ var Text = function(parentEl) {
var tokens = session.getTokens(row); var tokens = session.getTokens(row);
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) { foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
if (placeholder) { if (placeholder != null) {
renderTokens.push({ renderTokens.push({
type: "fold", type: "fold",
value: placeholder value: placeholder