diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index f6744907..b896e640 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -1642,6 +1642,7 @@ var EditSession = function(text, mode) { len = lastRow - firstRow; } + this.$updating = true; if (len != 0) { if (action.indexOf("remove") != -1) { this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len); @@ -1734,6 +1735,7 @@ var EditSession = function(text, mode) { if (useWrapMode && this.$wrapData.length != this.doc.getLength()) { console.error("doc.getLength() and $wrapData.length have to be the same!"); } + this.$updating = false; if (useWrapMode) this.$updateWrapData(firstRow, lastRow); diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index 765ec81c..f0fc274a 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -384,11 +384,13 @@ function Folding() { newFoldLine.start.column = folds[0].start.column; } - if (this.$useWrapMode) - this.$updateWrapData(startRow, endRow); - else - this.$updateRowLengthCache(startRow, endRow); - + if (!this.$updating) { + if (this.$useWrapMode) + this.$updateWrapData(startRow, endRow); + else + this.$updateRowLengthCache(startRow, endRow); + } + // Notify that fold data has changed. this.$modified = true; this._emit("changeFold", { data: fold }); diff --git a/lib/ace/edit_session_test.js b/lib/ace/edit_session_test.js index 68581679..0af3467d 100644 --- a/lib/ace/edit_session_test.js +++ b/lib/ace/edit_session_test.js @@ -899,7 +899,25 @@ module.exports = { return session; }, - + + "test delete fold with wrap enabled": function() { + var session = new EditSession(""); + session.setValue([ + "This is some placeholder text that will be folded inline.", + "This is some placeholder text that will be folded inline.", + "More text.", + "
The cursor in this paragraph text will be offset by 1 row.
", + "
Everything after this will be offset as well due to the folds in the row before too.
" + ].join("\n")); + session.addFold('...', new Range(0, 8, 0, 42)); + session.addFold('...', new Range(1, 8, 1, 42)); + session.addFold('...', new Range(3, 7, 3, 51)); + session.setOption("wrap", 40); + session.remove(new Range(0,0, 2, 5)); + + assert.equal(session.$wrapData + "", [[], [], [40, 76]] + ""); + }, + "test add fold": function() { var session = createFoldTestSession(); var fold; diff --git a/lib/ace/editor.js b/lib/ace/editor.js index b331f2ac..0abcecbf 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1364,6 +1364,7 @@ var Editor = function(renderer, session) { var sel = this.selection; var doc = this.session; var range = sel.getRange(); + var reverse = sel.isBackwards(); if (range.isEmpty()) { var row = range.start.row; doc.duplicateLines(row, row);