fix #1337 bad interaction of removeFolds and updateWrapData
This commit is contained in:
parent
cf74db8e1d
commit
4be0153e2b
4 changed files with 29 additions and 6 deletions
|
|
@ -1642,6 +1642,7 @@ var EditSession = function(text, mode) {
|
||||||
len = lastRow - firstRow;
|
len = lastRow - firstRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$updating = true;
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
if (action.indexOf("remove") != -1) {
|
if (action.indexOf("remove") != -1) {
|
||||||
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
|
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
|
||||||
|
|
@ -1734,6 +1735,7 @@ var EditSession = function(text, mode) {
|
||||||
if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
|
if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
|
||||||
console.error("doc.getLength() and $wrapData.length have to be the same!");
|
console.error("doc.getLength() and $wrapData.length have to be the same!");
|
||||||
}
|
}
|
||||||
|
this.$updating = false;
|
||||||
|
|
||||||
if (useWrapMode)
|
if (useWrapMode)
|
||||||
this.$updateWrapData(firstRow, lastRow);
|
this.$updateWrapData(firstRow, lastRow);
|
||||||
|
|
|
||||||
|
|
@ -384,10 +384,12 @@ function Folding() {
|
||||||
newFoldLine.start.column = folds[0].start.column;
|
newFoldLine.start.column = folds[0].start.column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.$updating) {
|
||||||
if (this.$useWrapMode)
|
if (this.$useWrapMode)
|
||||||
this.$updateWrapData(startRow, endRow);
|
this.$updateWrapData(startRow, endRow);
|
||||||
else
|
else
|
||||||
this.$updateRowLengthCache(startRow, endRow);
|
this.$updateRowLengthCache(startRow, endRow);
|
||||||
|
}
|
||||||
|
|
||||||
// Notify that fold data has changed.
|
// Notify that fold data has changed.
|
||||||
this.$modified = true;
|
this.$modified = true;
|
||||||
|
|
|
||||||
|
|
@ -900,6 +900,24 @@ module.exports = {
|
||||||
return session;
|
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.",
|
||||||
|
"<p>The cursor in this paragraph text will be offset by 1 row.<p>",
|
||||||
|
"<p>Everything after this will be offset as well due to the folds in the row before too.</p>"
|
||||||
|
].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() {
|
"test add fold": function() {
|
||||||
var session = createFoldTestSession();
|
var session = createFoldTestSession();
|
||||||
var fold;
|
var fold;
|
||||||
|
|
|
||||||
|
|
@ -1364,6 +1364,7 @@ var Editor = function(renderer, session) {
|
||||||
var sel = this.selection;
|
var sel = this.selection;
|
||||||
var doc = this.session;
|
var doc = this.session;
|
||||||
var range = sel.getRange();
|
var range = sel.getRange();
|
||||||
|
var reverse = sel.isBackwards();
|
||||||
if (range.isEmpty()) {
|
if (range.isEmpty()) {
|
||||||
var row = range.start.row;
|
var row = range.start.row;
|
||||||
doc.duplicateLines(row, row);
|
doc.duplicateLines(row, row);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue