From 2bd78cd47fad408a87059dd169c074ec05c45c8c Mon Sep 17 00:00:00 2001 From: yosmoc Date: Mon, 21 May 2018 22:56:52 +0200 Subject: [PATCH] update cursor position after expanding the link --- browser/components/CodeEditor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 7dfb6125..d7b16001 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -322,8 +322,9 @@ export default class CodeEditor extends React.Component { const cursor = editor.getCursor() const LinkWithTitle = `[${parsedResponse.title}](${pastedTxt})` const newValue = value.replace(taggedUrl, LinkWithTitle) + const newCursor = Object.assign({}, cursor, { ch: cursor.ch + newValue.length - value.length }) editor.setValue(newValue) - editor.setCursor(cursor) + editor.setCursor(newCursor) }).catch((e) => { const value = editor.getValue() const newValue = value.replace(taggedUrl, pastedTxt)