Rename the 'delete' delta action to 'remove'
Matches previous naming convention.
This commit is contained in:
parent
6fe381f633
commit
f2a2e4e1a8
10 changed files with 24 additions and 24 deletions
|
|
@ -133,7 +133,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELTA ENVELOPS POINT (delete only): Move point to delta start.
|
// DELTA ENVELOPS POINT (delete only): Move point to delta start.
|
||||||
if (delta.action != 'delete')
|
if (delta.action != 'remove')
|
||||||
throw 'Delete action expected.';
|
throw 'Delete action expected.';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ function throwDeltaError(delta, errorText){
|
||||||
function validateDelta(lines, delta) {
|
function validateDelta(lines, delta) {
|
||||||
|
|
||||||
// Validate action.
|
// Validate action.
|
||||||
if (delta.action != 'insert' && delta.action != 'delete')
|
if (delta.action != 'insert' && delta.action != 'remove')
|
||||||
fnThrow('Delta action must be "insert" or "delete".');
|
fnThrow('Delta action must be "insert" or "remove".');
|
||||||
|
|
||||||
// Validate lines.
|
// Validate lines.
|
||||||
if (!delta.lines instanceof Array)
|
if (!delta.lines instanceof Array)
|
||||||
|
|
@ -103,7 +103,7 @@ exports.applyDelta = function(lines, delta) {
|
||||||
lines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
|
lines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'remove':
|
||||||
lines[row] = line.substring(0, startColumn) + line.substring(endColumn);
|
lines[row] = line.substring(0, startColumn) + line.substring(endColumn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ exports.applyDelta = function(lines, delta) {
|
||||||
joinLineWithNext(lines, delta.range.end.row);
|
joinLineWithNext(lines, delta.range.end.row);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'remove':
|
||||||
splitLine(lines, delta.range.end);
|
splitLine(lines, delta.range.end);
|
||||||
splitLine(lines, delta.range.start);
|
splitLine(lines, delta.range.start);
|
||||||
lines.splice(
|
lines.splice(
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
|
|
||||||
if (len === 0) {
|
if (len === 0) {
|
||||||
this.lines[startRow] = null;
|
this.lines[startRow] = null;
|
||||||
} else if (delta.action == "delete") {
|
} else if (delta.action == 'remove') {
|
||||||
this.lines.splice(startRow, len + 1, null);
|
this.lines.splice(startRow, len + 1, null);
|
||||||
this.states.splice(startRow, len + 1, null);
|
this.states.splice(startRow, len + 1, null);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ var Document = function(textOrLines) {
|
||||||
* * `"insert"`
|
* * `"insert"`
|
||||||
* * `range`: the [[Range]] of the change within the document
|
* * `range`: the [[Range]] of the change within the document
|
||||||
* * `lines`: the lines being added
|
* * `lines`: the lines being added
|
||||||
* * `"delete"`
|
* * `"remove"`
|
||||||
* * `range`: the [[Range]] of the change within the document
|
* * `range`: the [[Range]] of the change within the document
|
||||||
* * `lines`: the lines being removed
|
* * `lines`: the lines being removed
|
||||||
*
|
*
|
||||||
|
|
@ -395,7 +395,7 @@ var Document = function(textOrLines) {
|
||||||
// Apply delta (emits change).
|
// Apply delta (emits change).
|
||||||
range = this.$getClippedRange(range);
|
range = this.$getClippedRange(range);
|
||||||
this.applyDelta({
|
this.applyDelta({
|
||||||
action: 'delete',
|
action: 'remove',
|
||||||
range: range,
|
range: range,
|
||||||
lines: this.getLinesForRange(range),
|
lines: this.getLinesForRange(range),
|
||||||
});
|
});
|
||||||
|
|
@ -418,7 +418,7 @@ var Document = function(textOrLines) {
|
||||||
|
|
||||||
// Apply delta (emits change).
|
// Apply delta (emits change).
|
||||||
this.applyDelta({
|
this.applyDelta({
|
||||||
action: "delete",
|
action: 'remove',
|
||||||
range: range,
|
range: range,
|
||||||
lines: this.getLinesForRange(range)
|
lines: this.getLinesForRange(range)
|
||||||
});
|
});
|
||||||
|
|
@ -455,7 +455,7 @@ var Document = function(textOrLines) {
|
||||||
|
|
||||||
// Apply delta (emits change).
|
// Apply delta (emits change).
|
||||||
this.applyDelta({
|
this.applyDelta({
|
||||||
action: "delete",
|
action: 'remove',
|
||||||
range: range,
|
range: range,
|
||||||
lines: this.getLinesForRange(range)
|
lines: this.getLinesForRange(range)
|
||||||
});
|
});
|
||||||
|
|
@ -474,7 +474,7 @@ var Document = function(textOrLines) {
|
||||||
if (row < this.getLength() - 1 && row >= 0) {
|
if (row < this.getLength() - 1 && row >= 0) {
|
||||||
// Apply delta (emits change).
|
// Apply delta (emits change).
|
||||||
this.applyDelta({
|
this.applyDelta({
|
||||||
action: "delete",
|
action: 'remove',
|
||||||
range: new Range(row, this.getLine(row).length, row + 1, 0),
|
range: new Range(row, this.getLine(row).length, row + 1, 0),
|
||||||
lines: ['', '']
|
lines: ['', '']
|
||||||
});
|
});
|
||||||
|
|
@ -516,7 +516,7 @@ var Document = function(textOrLines) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies all changes in `deltas` to the document.
|
* Applies all changes in `deltas` to the document.
|
||||||
* @param {Array} deltas An array of delta objects (can include 'insert' and 'delete' actions)
|
* @param {Array} deltas An array of delta objects (can include 'insert' and 'remove' actions)
|
||||||
**/
|
**/
|
||||||
this.applyDeltas = function(deltas) {
|
this.applyDeltas = function(deltas) {
|
||||||
for (var i=0; i<deltas.length; i++) {
|
for (var i=0; i<deltas.length; i++) {
|
||||||
|
|
@ -526,7 +526,7 @@ var Document = function(textOrLines) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverts all changes in `deltas` from the document.
|
* Reverts all changes in `deltas` from the document.
|
||||||
* @param {Array} deltas An array of delta objects (can include 'insert' and 'delete' actions)
|
* @param {Array} deltas An array of delta objects (can include 'insert' and 'remove' actions)
|
||||||
**/
|
**/
|
||||||
this.revertDeltas = function(deltas) {
|
this.revertDeltas = function(deltas) {
|
||||||
for (var i=deltas.length-1; i>=0; i--) {
|
for (var i=deltas.length-1; i>=0; i--) {
|
||||||
|
|
@ -536,7 +536,7 @@ var Document = function(textOrLines) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies `delta` to the document.
|
* Applies `delta` to the document.
|
||||||
* @param {Object} delta A delta object (can include 'insert' and 'delete' actions)
|
* @param {Object} delta A delta object (can include 'insert' and 'remove' actions)
|
||||||
**/
|
**/
|
||||||
this.applyDelta = function(delta) {
|
this.applyDelta = function(delta) {
|
||||||
applyDelta(this.$lines, delta);
|
applyDelta(this.$lines, delta);
|
||||||
|
|
@ -545,12 +545,12 @@ var Document = function(textOrLines) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverts `delta` from the document.
|
* Reverts `delta` from the document.
|
||||||
* @param {Object} delta A delta object (can include 'insert' and 'delete' actions)
|
* @param {Object} delta A delta object (can include 'insert' and 'remove' actions)
|
||||||
**/
|
**/
|
||||||
this.revertDelta = function(delta)
|
this.revertDelta = function(delta)
|
||||||
{
|
{
|
||||||
this.applyDelta({
|
this.applyDelta({
|
||||||
action: (delta.action == 'insert' ? 'delete' : 'insert'),
|
action: (delta.action == 'insert' ? 'remove' : 'insert'),
|
||||||
range: delta.range.clone(),
|
range: delta.range.clone(),
|
||||||
lines: delta.lines.slice()
|
lines: delta.lines.slice()
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1685,7 +1685,7 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
this.$updating = true;
|
this.$updating = true;
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
if (action == "delete") {
|
if (action == 'remove') {
|
||||||
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
|
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
|
||||||
|
|
||||||
var foldLines = this.$foldData;
|
var foldLines = this.$foldData;
|
||||||
|
|
@ -1760,7 +1760,7 @@ var EditSession = function(text, mode) {
|
||||||
// Realign folds. E.g. if you add some new chars before a fold, the
|
// Realign folds. E.g. if you add some new chars before a fold, the
|
||||||
// fold should "move" to the right.
|
// fold should "move" to the right.
|
||||||
len = Math.abs(e.data.range.start.column - e.data.range.end.column);
|
len = Math.abs(e.data.range.start.column - e.data.range.end.column);
|
||||||
if (action == "delete") {
|
if (action == 'remove') {
|
||||||
// Get all the folds in the change range and remove them.
|
// Get all the folds in the change range and remove them.
|
||||||
removedFolds = this.getFoldsInRange(e.data.range);
|
removedFolds = this.getFoldsInRange(e.data.range);
|
||||||
this.removeFolds(removedFolds);
|
this.removeFolds(removedFolds);
|
||||||
|
|
|
||||||
|
|
@ -833,7 +833,7 @@ function Folding() {
|
||||||
|
|
||||||
if (len === 0) {
|
if (len === 0) {
|
||||||
this.foldWidgets[firstRow] = null;
|
this.foldWidgets[firstRow] = null;
|
||||||
} else if (delta.action == "delete") {
|
} else if (delta.action == 'remove') {
|
||||||
this.foldWidgets.splice(firstRow, len + 1, null);
|
this.foldWidgets.splice(firstRow, len + 1, null);
|
||||||
} else {
|
} else {
|
||||||
var args = Array(len + 1);
|
var args = Array(len + 1);
|
||||||
|
|
|
||||||
|
|
@ -581,7 +581,7 @@ var onSelectionChange = function(evt) {
|
||||||
var onChange = function(evt) {
|
var onChange = function(evt) {
|
||||||
var data = evt.data;
|
var data = evt.data;
|
||||||
switch (data.action) {
|
switch (data.action) {
|
||||||
case 'delete':
|
case 'remove':
|
||||||
cvox.Api.speak(data.text, 0, DELETED_PROP);
|
cvox.Api.speak(data.text, 0, DELETED_PROP);
|
||||||
/* Let the future cursor change event know it's from text change. */
|
/* Let the future cursor change event know it's from text change. */
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ var Gutter = function(parentEl) {
|
||||||
var len = range.end.row - firstRow;
|
var len = range.end.row - firstRow;
|
||||||
if (len === 0) {
|
if (len === 0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (delta.action == "delete") {
|
} else if (delta.action == 'remove') {
|
||||||
this.$annotations.splice(firstRow, len + 1, null);
|
this.$annotations.splice(firstRow, len + 1, null);
|
||||||
} else {
|
} else {
|
||||||
var args = new Array(len + 1);
|
var args = new Array(len + 1);
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ function LineWidgets(session) {
|
||||||
|
|
||||||
if (len === 0) {
|
if (len === 0) {
|
||||||
// return
|
// return
|
||||||
} else if (delta.action == "delete") {
|
} else if (delta.action == 'remove') {
|
||||||
var removed = cells.splice(startRow + 1, len);
|
var removed = cells.splice(startRow + 1, len);
|
||||||
removed.forEach(function(w) {
|
removed.forEach(function(w) {
|
||||||
w && this.removeLineWidget(w);
|
w && this.removeLineWidget(w);
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
||||||
newPos.column += lengthDiff;
|
newPos.column += lengthDiff;
|
||||||
this.doc.insertMergedLines(newPos, delta.lines);
|
this.doc.insertMergedLines(newPos, delta.lines);
|
||||||
}
|
}
|
||||||
} else if(delta.action === "delete") {
|
} else if(delta.action === 'remove') {
|
||||||
for (var i = this.others.length - 1; i >= 0; i--) {
|
for (var i = this.others.length - 1; i >= 0; i--) {
|
||||||
var otherPos = this.others[i];
|
var otherPos = this.others[i];
|
||||||
var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
|
var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
|
||||||
|
|
@ -191,7 +191,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
||||||
}
|
}
|
||||||
}.bind(this), 0);
|
}.bind(this), 0);
|
||||||
}
|
}
|
||||||
else if(range.start.column === this.pos.column && delta.action === "delete") {
|
else if(range.start.column === this.pos.column && delta.action === 'remove') {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
for (var i = 0; i < this.others.length; i++) {
|
for (var i = 0; i < this.others.length; i++) {
|
||||||
var other = this.others[i];
|
var other = this.others[i];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue