diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 2e27deca..53d0c3ca 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -316,11 +316,7 @@ var Editor = function(renderer, session) { this.renderer.updateCursor(); if (!this.$blockScrolling) { - var selection = this.getSelection(); - if (selection.isEmpty()) - this.renderer.scrollCursorIntoView(selection.getCursor()); - else - this.renderer.scrollSelectionIntoView(selection.getSelectionLead(), selection.getSelectionAnchor()); + this.renderer.scrollCursorIntoView(); } // move text input over the cursor @@ -1155,11 +1151,13 @@ var Editor = function(renderer, session) { if (!range) return replaced; - if(this.$tryReplace(range, replacement)) { + if (this.$tryReplace(range, replacement)) { replaced = 1; } - if (range !== null) + if (range !== null) { this.selection.setSelectionRange(range); + this.renderer.scrollSelectionIntoView(range.start, range.end); + } return replaced; }; @@ -1240,6 +1238,7 @@ var Editor = function(renderer, session) { var range = this.$search.find(this.session); if (range) { this.session.unfold(range); + this.$blockScrolling += 1; this.selection.setSelectionRange(range); this.$blockScrolling -= 1; @@ -1251,6 +1250,8 @@ var Editor = function(renderer, session) { //@todo scroll X //if (!this.isRowFullyVisible(cursor.row)) //this.scrollToLine(cursor.row, true); + + this.renderer.scrollSelectionIntoView(range.start, range.end); } };