From 2ade7175ba187cce998597fbc29df25f6660ef74 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Mon, 22 Jun 2009 12:42:27 +0000 Subject: [PATCH] Added restauration of scroll state inside replaceSelection SVN revision: 2215 --- scripts/elcode.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/elcode.js b/scripts/elcode.js index ef3e4443..bac0e6bd 100755 --- a/scripts/elcode.js +++ b/scripts/elcode.js @@ -38,7 +38,8 @@ function replaceSelection(doc, text, newSelection, cursorPos) stop--; end = text.textLength; endtext = text.value.substring(stop, end); - starttext = text.value.substring(0, start); + starttext = text.value.substring(0, start); + oldTop = text.scrollTop; text.value = starttext + newSelection + endtext; if (start != stop) { text.selectionStart = start; @@ -46,7 +47,8 @@ function replaceSelection(doc, text, newSelection, cursorPos) } else { text.selectionStart = start + cursorPos; text.selectionEnd = text.selectionStart; - } + } + text.scrollTop = oldTop; } }