kopia lustrzana https://github.com/c9/core
fix +9984 Rename variable broken for two instances on the same line
rodzic
faa9773840
commit
515478ef96
|
@ -1158,7 +1158,7 @@ EditSession.$uid = 0;
|
|||
this.addFolds(delta.folds);
|
||||
}
|
||||
}
|
||||
if (!dontSelect) {
|
||||
if (!dontSelect && this.$undoSelect) {
|
||||
// console.log(deltas.selectionBefore + "uuu")
|
||||
if (deltas.selectionBefore)
|
||||
this.selection.fromJSON(deltas.selectionBefore);
|
||||
|
@ -1187,7 +1187,7 @@ EditSession.$uid = 0;
|
|||
}
|
||||
}
|
||||
|
||||
if (!dontSelect) {
|
||||
if (!dontSelect && this.$undoSelect) {
|
||||
if (deltas.selectionAfter)
|
||||
this.selection.fromJSON(deltas.selectionAfter);
|
||||
else
|
||||
|
|
|
@ -90,21 +90,21 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
var _self = this;
|
||||
var doc = this.doc;
|
||||
var session = this.session;
|
||||
var pos = this.$pos;
|
||||
|
||||
this.selectionBefore = session.selection.toJSON();
|
||||
if (session.selection.inMultiSelectMode)
|
||||
session.selection.toSingleRange();
|
||||
|
||||
this.pos = doc.createAnchor(pos.row, pos.column);
|
||||
this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
|
||||
this.pos.on("change", function(event) {
|
||||
session.removeMarker(_self.markerId);
|
||||
_self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
|
||||
});
|
||||
this.pos = doc.createAnchor(this.$pos.row, this.$pos.column);
|
||||
var pos = this.pos;
|
||||
pos.$insertRight = true;
|
||||
pos.detach();
|
||||
pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
|
||||
this.others = [];
|
||||
this.$others.forEach(function(other) {
|
||||
var anchor = doc.createAnchor(other.row, other.column);
|
||||
anchor.$insertRight = true;
|
||||
anchor.detach();
|
||||
_self.others.push(anchor);
|
||||
});
|
||||
session.setUndoSelect(false);
|
||||
|
@ -117,16 +117,12 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
*
|
||||
**/
|
||||
this.showOtherMarkers = function() {
|
||||
if(this.othersActive) return;
|
||||
if (this.othersActive) return;
|
||||
var session = this.session;
|
||||
var _self = this;
|
||||
this.othersActive = true;
|
||||
this.others.forEach(function(anchor) {
|
||||
anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
|
||||
anchor.on("change", function(event) {
|
||||
session.removeMarker(anchor.markerId);
|
||||
anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -137,7 +133,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
*
|
||||
**/
|
||||
this.hideOtherMarkers = function() {
|
||||
if(!this.othersActive) return;
|
||||
if (!this.othersActive) return;
|
||||
this.othersActive = false;
|
||||
for (var i = 0; i < this.others.length; i++) {
|
||||
this.session.removeMarker(this.others[i].markerId);
|
||||
|
@ -151,64 +147,61 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
*
|
||||
**/
|
||||
this.onUpdate = function(delta) {
|
||||
if (this.$updating)
|
||||
return this.updateAnchors(delta);
|
||||
|
||||
var range = delta;
|
||||
if(range.start.row !== range.end.row) return;
|
||||
if(range.start.row !== this.pos.row) return;
|
||||
if (this.$updating) return;
|
||||
if (range.start.row !== range.end.row) return;
|
||||
if (range.start.row !== this.pos.row) return;
|
||||
this.$updating = true;
|
||||
var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
|
||||
|
||||
if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
|
||||
var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1;
|
||||
var distanceFromStart = range.start.column - this.pos.column;
|
||||
|
||||
this.updateAnchors(delta);
|
||||
|
||||
if (inMainRange)
|
||||
this.length += lengthDiff;
|
||||
if(!this.session.$fromUndo) {
|
||||
if(delta.action === 'insert') {
|
||||
|
||||
if (inMainRange && !this.session.$fromUndo) {
|
||||
if (delta.action === 'insert') {
|
||||
for (var i = this.others.length - 1; i >= 0; i--) {
|
||||
var otherPos = this.others[i];
|
||||
var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
|
||||
if(otherPos.row === range.start.row && range.start.column < otherPos.column)
|
||||
newPos.column += lengthDiff;
|
||||
this.doc.insertMergedLines(newPos, delta.lines);
|
||||
}
|
||||
} else if(delta.action === 'remove') {
|
||||
} else if (delta.action === 'remove') {
|
||||
for (var i = this.others.length - 1; i >= 0; i--) {
|
||||
var otherPos = this.others[i];
|
||||
var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
|
||||
if(otherPos.row === range.start.row && range.start.column < otherPos.column)
|
||||
newPos.column += lengthDiff;
|
||||
this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
|
||||
}
|
||||
}
|
||||
// Special case: insert in beginning
|
||||
if(range.start.column === this.pos.column && delta.action === 'insert') {
|
||||
setTimeout(function() {
|
||||
this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
|
||||
for (var i = 0; i < this.others.length; i++) {
|
||||
var other = this.others[i];
|
||||
var newPos = {row: other.row, column: other.column - lengthDiff};
|
||||
if(other.row === range.start.row && range.start.column < other.column)
|
||||
newPos.column += lengthDiff;
|
||||
other.setPosition(newPos.row, newPos.column);
|
||||
}
|
||||
}.bind(this), 0);
|
||||
}
|
||||
else if(range.start.column === this.pos.column && delta.action === 'remove') {
|
||||
setTimeout(function() {
|
||||
for (var i = 0; i < this.others.length; i++) {
|
||||
var other = this.others[i];
|
||||
if(other.row === range.start.row && range.start.column < other.column) {
|
||||
other.setPosition(other.row, other.column - lengthDiff);
|
||||
}
|
||||
}
|
||||
}.bind(this), 0);
|
||||
}
|
||||
}
|
||||
this.pos._emit("change", {value: this.pos});
|
||||
for (var i = 0; i < this.others.length; i++) {
|
||||
this.others[i]._emit("change", {value: this.others[i]});
|
||||
}
|
||||
}
|
||||
|
||||
this.$updating = false;
|
||||
this.updateMarkers();
|
||||
};
|
||||
|
||||
this.updateAnchors = function(delta) {
|
||||
this.pos.onChange(delta);
|
||||
for (var i = this.others.length; i--;)
|
||||
this.others[i].onChange(delta);
|
||||
this.updateMarkers();
|
||||
};
|
||||
|
||||
this.updateMarkers = function() {
|
||||
if (this.$updating)
|
||||
return;
|
||||
var _self = this;
|
||||
var session = this.session;
|
||||
var updateMarker = function(pos, className) {
|
||||
session.removeMarker(pos.markerId);
|
||||
pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column+_self.length), className, null, false);
|
||||
};
|
||||
updateMarker(this.pos, this.mainClass);
|
||||
for (var i = this.others.length; i--;)
|
||||
updateMarker(this.others[i], this.othersClass);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -237,14 +230,10 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
*
|
||||
**/
|
||||
this.detach = function() {
|
||||
this.session.removeMarker(this.markerId);
|
||||
this.session.removeMarker(this.pos && this.pos.markerId);
|
||||
this.hideOtherMarkers();
|
||||
this.doc.removeEventListener("change", this.$onUpdate);
|
||||
this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
|
||||
this.pos.detach();
|
||||
for (var i = 0; i < this.others.length; i++) {
|
||||
this.others[i].detach();
|
||||
}
|
||||
this.session.setUndoSelect(true);
|
||||
this.session = null;
|
||||
};
|
||||
|
@ -256,8 +245,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
*
|
||||
**/
|
||||
this.cancel = function() {
|
||||
if(this.$undoStackDepth === -1)
|
||||
throw Error("Canceling placeholders only supported with undo manager attached to session.");
|
||||
if (this.$undoStackDepth === -1)
|
||||
return;
|
||||
var undoManager = this.session.getUndoManager();
|
||||
var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
|
||||
for (var i = 0; i < undosRequired; i++) {
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"c9"
|
||||
],
|
||||
"c9plugins": {
|
||||
"c9.ide.language": "#2a4a36fc18",
|
||||
"c9.ide.language": "#2b5184c931",
|
||||
"c9.ide.language.css": "#a649f2a710",
|
||||
"c9.ide.language.generic": "#77d43cfaf0",
|
||||
"c9.ide.language.html": "#0f4078c187",
|
||||
|
|
Ładowanie…
Reference in New Issue