From 0610c9fe986a96dc2b6670e30dae469298902b4e Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 1 Sep 2021 14:54:52 -0400 Subject: [PATCH] fix injecting images putting the cursor midway into the next line of text. --- client/homebrew/editor/editor.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 213e35f71..20f084c28 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -76,7 +76,8 @@ const Editor = createClass({ const cursorPos = this.refs.codeEditor.getCursorPosition(); lines[cursorPos.line] = splice(lines[cursorPos.line], cursorPos.ch, injectText); - this.refs.codeEditor.setCursorPosition(cursorPos.line + injectText.split('\n').length, cursorPos.ch + injectText.length); + const injectLines = injectText.split('\n'); + this.refs.codeEditor.setCursorPosition(cursorPos.line + injectLines.length, cursorPos.ch + injectLines[injectLines.length - 1].length); if(this.isText()) this.props.onTextChange(lines.join('\n')); if(this.isStyle()) this.props.onStyleChange(lines.join('\n'));