Just checked an idea for "format only the selected code" in my environment.
At the end it is extremly easy to implement.
Should be similiar for prettier
var code = Espruino.Core.EditorJavaScript.getCode();
var selected = Espruino.Core.EditorJavaScript.getSelectedCode();
if(selected) code = code.replace(selected,js_beautify(selected,options) + "\n"); //had to add linefeed for beautify, don't know wether prettier needs this
else code = js_beautify(code,options);
Espruino.Core.EditorJavaScript.setCode(code);
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.
Just checked an idea for "format only the selected code" in my environment.
At the end it is extremly easy to implement.
Should be similiar for prettier