fix up/down arrow handling when selection is present

This commit is contained in:
nightwing 2013-02-24 12:02:35 +04:00
commit b4e9790763

View file

@ -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;
});
});