From a71f50ac9ad3ad3639531d827383616a2ca20d33 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Sun, 9 Jan 2011 23:56:42 +0100 Subject: [PATCH] Fix bug in Selection.moveCursorBy. Use desiredColumn only if chars == 0. --- lib/ace/selection.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/ace/selection.js b/lib/ace/selection.js index a0b60301..b630d763 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -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); } };