From 7206c60dc6df3e6d572003f1b6508c3f6788f0af Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 14 Feb 2011 07:54:28 +0100 Subject: [PATCH] replace all should not change the selection --- lib/ace/editor.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 81227a45..1fa042df 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1016,13 +1016,16 @@ var Editor =function(renderer, session) { if (!ranges.length) return; + var selection = this.getSelectionRange(); this.clearSelection(); this.selection.moveCursorTo(0, 0); + this.$blockScrolling += 1; for (var i = ranges.length - 1; i >= 0; --i) this.$tryReplace(ranges[i], replacement); - if (ranges[0] !== null) - this.selection.setSelectionRange(ranges[0]); + this.$blockScrolling -= 1; + + this.selection.setSelectionRange(selection); }, this.$tryReplace = function(range, replacement) {