do not freeze browser when calling fold all second time

This commit is contained in:
nightwing 2013-11-24 16:15:52 +04:00
commit a910b8ee18

View file

@ -128,13 +128,9 @@ function Folding() {
var folds = [];
var foldLines = this.$foldData;
function addFold(fold) {
folds.push(fold);
}
for (var i = 0; i < foldLines.length; i++)
for (var j = 0; j < foldLines[i].folds.length; j++)
addFold(foldLines[i].folds[j]);
folds.push(foldLines[i].folds[j]);
return folds;
};
@ -285,7 +281,7 @@ function Folding() {
// --- Some checking ---
if (!(startRow < endRow ||
startRow == endRow && startColumn <= endColumn - 2))
startRow == endRow && startColumn < endColumn - 2))
throw new Error("The range has to be at least 2 characters width");
var startFold = this.getFoldAt(startRow, startColumn, 1);
@ -655,12 +651,15 @@ function Folding() {
if (range && range.isMultiLine()
&& range.end.row <= endRow
&& range.start.row >= startRow
) try {
var fold = this.addFold("...", range);
fold.collapseChildren = depth;
// addFold can change the range
) {
row = range.end.row;
} catch(e) {}
try {
// addFold can change the range
var fold = this.addFold("...", range);
if (fold)
fold.collapseChildren = depth;
} catch(e) {}
}
}
};
@ -753,6 +752,8 @@ function Folding() {
};
this.$toggleFoldWidget = function(row, options) {
if (!this.getFoldWidget)
return;
var type = this.getFoldWidget(row);
var line = this.getLine(row);