Fix EditSession.removeFolds: Using the folds of a foldLine might cause unexpected behavior. Clone the passed in array.
This commit is contained in:
parent
dd121334a6
commit
2be2386603
1 changed files with 9 additions and 7 deletions
|
|
@ -968,12 +968,6 @@ var EditSession = function(text, mode) {
|
|||
this.removeFolds(this.getFoldsInRange(e.data.range));
|
||||
len = -len;
|
||||
}
|
||||
// if (action.indexOf("insert") != -1) {
|
||||
// column = start.column;
|
||||
// } else {
|
||||
// column = end.column;
|
||||
// len = -len;
|
||||
// }
|
||||
var foldLine = this.getFoldLine(firstRow);
|
||||
if (foldLine) {
|
||||
foldLine.addRemoveChars(firstRow, start.column, len);
|
||||
|
|
@ -1927,7 +1921,15 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
|
||||
this.removeFolds = function(folds) {
|
||||
folds.forEach(function(fold) {
|
||||
// We need to clone the folds array passed in as it might be the folds
|
||||
// array of a fold line and as we call this.removeFold(fold), folds
|
||||
// are removed from folds and changes the current index.
|
||||
var cloneFolds = [];
|
||||
for (var i = 0; i < folds.length; i++) {
|
||||
cloneFolds.push(folds[i]);
|
||||
}
|
||||
|
||||
cloneFolds.forEach(function(fold) {
|
||||
this.removeFold(fold);
|
||||
}, this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue