diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 8c2472eb..e293eadd 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -982,7 +982,7 @@ var Editor = function(renderer, session) { this.renderer.animateScrolling(function() { renderer.scrollBy(0, rows * config.lineHeight); if (select != null) - renderer.scrollCursorIntoView(); + renderer.scrollCursorIntoView(null, 0.5); }, this); }; @@ -1262,17 +1262,23 @@ var Editor = function(renderer, session) { this.$blockScrolling -= 1; this.renderer.animateScrolling(function() { - this.renderer.scrollSelectionIntoView(range.start, range.end); + this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5); }, this); } }; this.undo = function() { + this.$blockScrolling++; this.session.getUndoManager().undo(); + this.$blockScrolling--; + renderer.scrollCursorIntoView(null, 0.5); }; this.redo = function() { + this.$blockScrolling++; this.session.getUndoManager().redo(); + this.$blockScrolling--; + renderer.scrollCursorIntoView(null, 0.5); }; this.destroy = function() { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 06e1c979..15dc8ff2 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -678,13 +678,13 @@ var VirtualRenderer = function(container, theme) { this.$cursorLayer.showCursor(); }; - this.scrollSelectionIntoView = function(anchor, lead) { + this.scrollSelectionIntoView = function(anchor, lead, offset) { // first scroll anchor into view then scroll lead into view - this.scrollCursorIntoView(anchor); - this.scrollCursorIntoView(lead); + this.scrollCursorIntoView(anchor, offset); + this.scrollCursorIntoView(lead, offset); }; - this.scrollCursorIntoView = function(cursor) { + this.scrollCursorIntoView = function(cursor, offset) { // the editor is not visible if (this.$size.scrollerHeight === 0) return; @@ -695,10 +695,12 @@ var VirtualRenderer = function(container, theme) { var top = pos.top; if (this.scrollTop > top) { + if (offset) + top -= offset * this.$size.scrollerHeight; this.session.setScrollTop(top); - } - - if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) { + } else if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) { + if (offset) + top += offset * this.$size.scrollerHeight; this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight); } @@ -708,9 +710,7 @@ var VirtualRenderer = function(container, theme) { if (left < this.$padding + 2 * this.layerConfig.characterWidth) left = 0; this.session.setScrollLeft(left); - } - - if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { + } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); } };