git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@20011
e93f8b46-1217-0410-a6f0-
8f06a7374b81
} else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
this.textarea.value = this.textarea.value.substring(0, start) + subst +
this.textarea.value.substring(end);
- if (sel) {
+ if (sel || (!prefix && start === end)) {
this.textarea.setSelectionRange(start + subst.length, start + subst.length);
} else {
this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);