From 56ce472929aa8d2802cc62d7d65552766e92c8bb Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Tue, 3 Apr 2007 18:20:20 +0000 Subject: [PATCH] Fixed bug with selection after blank SVN revision: 1829 --- scripts/elcode.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/elcode.js b/scripts/elcode.js index 891f667b..d2c009fe 100755 --- a/scripts/elcode.js +++ b/scripts/elcode.js @@ -6,7 +6,8 @@ function getSelection(text) rng.colapse; return rng.text; } else if (browser == 'Mozilla') - if (text.selectionEnd > 0 && text.value.charAt(text.selectionEnd-1) == ' ') + if (text.selectionEnd > 0 && text.selectionEnd != text.selectionStart && + text.value.charAt(text.selectionEnd-1) == ' ') return text.value.substring(text.selectionStart, text.selectionEnd-1); else return text.value.substring(text.selectionStart, text.selectionEnd); @@ -31,7 +32,8 @@ function replaceSelection(doc, text, newSelection, cursorPos) } else if (browser == 'Mozilla') { start = text.selectionStart; stop = text.selectionEnd; - if (text.selectionEnd > 0 && text.value.charAt(text.selectionEnd-1) == ' ') + if (text.selectionEnd > 0 && text.selectionStart != text.selectionEnd && + text.value.charAt(text.selectionEnd-1) == ' ') stop--; end = text.textLength; endtext = text.value.substring(stop, end); @@ -69,7 +71,7 @@ function elcode1(text, tag, value, selection) else str = '['+tag+'='+value+']' + selection + '[/'+tag+']'; - if (tag == '') + if (tag == '') pos = value.length; else if (tag == 'LIST') pos = 11;