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) {
if (this.doc.getUseWrapMode()) {
var pos = this.doc.documentToScreenPosition(
var screenPos = this.doc.documentToScreenPosition(
this.selectionLead.row, this.selectionLead.column);
pos = this.doc.screenToDocumentPosition(
pos.row + rows, (this.$desiredColumn || pos.column));
this.moveCursorTo(pos.row, pos.column + chars, chars == 0);
var screenCol =
(chars == 0 && this.$desiredColumn) || screenPos.column;
var docPos = this.doc.screenToDocumentPosition(
screenPos.row + rows, screenCol);
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
} else {
this.moveCursorTo(this.selectionLead.row + rows,
(this.$desiredColumn || this.selectionLead.column) + chars,
chars == 0);
var docColumn =
(chars == 0 && this.$desiredColumn) || this.selectionLead.column;
this.moveCursorTo(
this.selectionLead.row + rows, docColumn + chars, chars == 0);
}
};