From 125d9bfbfd54fc66f03ebb673e4c9b125b04570b Mon Sep 17 00:00:00 2001 From: Jan Jongboom Date: Wed, 2 Nov 2011 10:03:04 +0000 Subject: [PATCH] Issue 489 --- build/demo/kitchen-sink-uncompressed.js | 17 ++++++++++++++++- lib/ace/selection.js | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/build/demo/kitchen-sink-uncompressed.js b/build/demo/kitchen-sink-uncompressed.js index 85d8321a..eccf480e 100644 --- a/build/demo/kitchen-sink-uncompressed.js +++ b/build/demo/kitchen-sink-uncompressed.js @@ -11855,8 +11855,23 @@ var Selection = function(session) { this.selectionLead.row, this.selectionLead.column ); - var screenCol = (chars == 0 && this.$desiredColumn) || screenPos.column; + + var screenCol = (chars === 0 && this.$desiredColumn) || screenPos.column; + + // so here is the deal. First checkout what the content of ur current and ur target line is + var currentLine = (this.session.getLines(screenPos.row, screenPos.row) || [""])[0], + targetLine = (this.session.getLines(screenPos.row + rows, screenPos.row + rows) || [""])[0]; + + // if you are at the EOL of your current line, and your targetline is all whitespace + if (currentLine.length === screenPos.column && targetLine.match(/^\s*$/)) { + // set the new column to the EOL of the target line + screenCol = this.session.getTabString(targetLine).length; + } + var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol); + + console.log(rows, chars, screenPos, currentLine, targetLine, screenCol, docPos); + this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0); }; diff --git a/lib/ace/selection.js b/lib/ace/selection.js index 5d315a25..1d76f8b1 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -123,7 +123,7 @@ var Selection = function(session) { }; var anchor = this.getSelectionAnchor(); - var lead = this.getSelectionLead(); + var lead = this.getSelectionLead(); var isBackwards = this.isBackwards();