From b4e979076330f6dcfb47d3d23aef1ef6eb5d4a29 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Feb 2013 12:02:35 +0400 Subject: [PATCH] fix up/down arrow handling when selection is present --- lib/ace/editor.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 72484840..8a62ffe2 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1800,6 +1800,10 @@ var Editor = function(renderer, session) { * **/ this.navigateUp = function(times) { + if (!this.selection.isEmpty() && !this.selection.isBackwards()) { + var selectionStart = this.selection.anchor.getPosition(); + return this.moveCursorToPosition(selectionStart); + } this.selection.clearSelection(); times = times || 1; this.selection.moveCursorBy(-times, 0); @@ -1812,6 +1816,10 @@ var Editor = function(renderer, session) { * **/ this.navigateDown = function(times) { + if (!this.selection.isEmpty() && this.selection.isBackwards()) { + var selectionEnd = this.selection.anchor.getPosition(); + return this.moveCursorToPosition(selectionEnd); + } this.selection.clearSelection(); times = times || 1; this.selection.moveCursorBy(times, 0); @@ -2220,4 +2228,4 @@ config.defineOptions(Editor.prototype, "editor", { }); exports.Editor = Editor; -}); +}); \ No newline at end of file