Help with script: maintaining position In draft

Hi. Can some one please help improve an existing script, delete line? Script is great to delete current line in draft but position of cursor goes to end of draft instead of moving to previous or next line of line that was deleted. Any suggestion on modifying? Thanks

Try modifying the script as follows, to update the selection:

let [st, len] = editor.getSelectedLineRange();
editor.setTextInRange(st, len, "");

if (st > 0) {
	editor.setSelectedRange(st - 1, 0);

Thanks Greg.

Tried it and works. Only thing is that when first line is deleted then it’ll jump to end of draft. It’s good enough anyway. Thanks.