textArea.LineNumAtCharPos returns wrong line?

Do I just not understand how this works or is this a bug?

I am trying to figure out which line of text the insertion point is on, so I am passing selStart to the lineNumAtCharPos function of a text area. If I’m at the beginning of the line or after the first character of the start of the line it returns the line number above the line it’s actually on. If I’m past the first 2 characters of the line it returns the correct value.

If it was just the beginning of the line I’d say that it’s counting the end of line character as being the previous line. But it’s the beginning of the line AND the first character on the line?

Looks like a similar bug to this one that is in feedback.

link text

I have added myself and my demo project to that report, thank you!