TextArea - SelStart vs LineNumAtCharPos

I am assuming there is a “bug” in TextArea (macOS)… and does anyone know of a “workaround”

I have this line of code

cl=theEditor.LineNumAtCharPos(theEditor.SelStart) // line the cursor is on 

theEditor is a TextArea control

here it the “problem”
as a test I typed in 8 characters


and got the following … CL=line #, SS=SelStart

CL=0 SS=1 … “1”
CL=0 SS=2 … “12”
CL=0 SS=3 … “123”
CL=0 SS=4 … 123"
CL=0 SS=5 … “1234”
CL=1 SS=6 … “1234”
CL=1 SS=7 … “1234”
CL=2 SS=8 … “1234”

SS 1 to 3 I expected CL=0 and got 0
SS 4 expected CL=1 but still 0
SS 5 expected CL=1 but still 0
SS 6 expected CL=2 but got 1
SS 7 expected CL=3 but got 1
SS 8 expected CL=4 but got 2

It seems to not consider any line that is “” or a single character
If the line consists of TWO or more characters it “increments” the linenumber… but any previous blank lines muff the calculation

this text has NO soft breaks (ie. no wrapping)

I tried this in 2018r3 and same thing

Perhaps a RegEx that can count the EndofLine in a limited length of text?

Hi Dave, looks like feedback://showreport?report_id=54078

I didn’t use SelStart just at first then checked EOL with more characters. As you tested the issue is when the command is executed at the first position.

Edit: Sorry, I forgot that you don’t use Feedback

more like “can’t”…

Ok… it seems LineNumAtCharPos has a huge bug… it doesn’t count TWO endoflines in a row as 2 lines… it counts 3 EOL as 2 lines unless the lines have something else in them


X is wrong, but Y seems to be correct… just a bit on the “expensive” side