@JumJumcode.replace(selected, ... is dangerous since it may also override other places that, by accident, contain the same code as the selection. There are better ways by using start and end of the selection and replacing only this part - but, again, let us leave this to another PR (that we'd be happy to receive from you!).
Edit: Have a look at https://codemirror.net/doc/manual.html#api and try using Espruino.Core.EditorJavaScript.getCodeMirror().replaceSelection(...). This should do the trick.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@JumJum
code.replace(selected, ...
is dangerous since it may also override other places that, by accident, contain the same code as the selection. There are better ways by using start and end of the selection and replacing only this part - but, again, let us leave this to another PR (that we'd be happy to receive from you!).Edit: Have a look at https://codemirror.net/doc/manual.html#api and try using
Espruino.Core.EditorJavaScript.getCodeMirror().replaceSelection(...)
. This should do the trick.