Fix bug in Selection.moveCursorBy. Use desiredColumn only if chars == 0.

This commit is contained in:
Julian Viereck 2011-01-09 23:56:42 +01:00
commit a71f50ac9a

View file

@ -390,15 +390,19 @@ var Selection = function(doc) {
this.moveCursorBy = function(rows, chars) { this.moveCursorBy = function(rows, chars) {
if (this.doc.getUseWrapMode()) { if (this.doc.getUseWrapMode()) {
var pos = this.doc.documentToScreenPosition( var screenPos = this.doc.documentToScreenPosition(
this.selectionLead.row, this.selectionLead.column); this.selectionLead.row, this.selectionLead.column);
pos = this.doc.screenToDocumentPosition( var screenCol =
pos.row + rows, (this.$desiredColumn || pos.column)); (chars == 0 && this.$desiredColumn) || screenPos.column;
this.moveCursorTo(pos.row, pos.column + chars, chars == 0);
var docPos = this.doc.screenToDocumentPosition(
screenPos.row + rows, screenCol);
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
} else { } else {
this.moveCursorTo(this.selectionLead.row + rows, var docColumn =
(this.$desiredColumn || this.selectionLead.column) + chars, (chars == 0 && this.$desiredColumn) || this.selectionLead.column;
chars == 0); this.moveCursorTo(
this.selectionLead.row + rows, docColumn + chars, chars == 0);
} }
}; };