diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index 8f8d5397e05..6ff564d54f4 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -461,7 +461,7 @@ export default Ember.Component.extend({ this.set('value', `${pre}${contents}${post}`); if (lines.length === 1 && tlen > 0) { - this._selectText(sel.start + hlen, contents.length - hlen - hlen); + this._selectText(sel.start + hlen, sel.value.length); } else { this._selectText(sel.start, contents.length); }