Greetings, folks!
I have an action Javascript (appended below) that moves the cursor to the end of the current line, but if there is a carriage return or line feed at the end of the line, it will move the cursor to the start of the next line. Not what I want.
Simply subtracting one character from the line length is a shoddy workaround, but only fails if the line is the last line in the text file.
Thoughts or suggestions?
(Please forgive me for being so rusty in JS!)
Blessings, and thank you!
βββββββββββββββββββββββββββββββββββββββ
// Move cursor to end of line
let [loc, len] = editor.getSelectedLineRange(),
str = editor.getTextInRange(loc, len);
editor.setTextInRange(loc, len, str);
// editor.setSelectedRange(loc + str.length, 0); // this includes the carriage return/line feed at the end of lines, and thus going to the start of the next line instead
editor.setSelectedRange(loc + str.length - 1, 0); // the shoddy workaround
editor.setSelectedText(ββ);
editor.activate();