diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 26ec17be5..e8d9cb69f 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -46,11 +46,19 @@ const CodeEditor = createClass({ makeBold : function() { const selection = this.codeMirror.getSelection(); this.codeMirror.replaceSelection(`**${selection}**`, 'around'); + if(selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 }); + } }, makeItalic : function() { const selection = this.codeMirror.getSelection(); this.codeMirror.replaceSelection(`*${selection}*`, 'around'); + if(selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); + } }, componentWillReceiveProps : function(nextProps){