TextArea.LineNumber Can't Handle Large Position Parameter

Xojo 2021r2.1

I have a TextArea with lots of lines, like 10,000 or more, and am trying to implement a simple search function:

Var Position As Integer =TextArea1.Text.IndexOf(SearchStart, searchText)
If position > -1 Then
  Var LineNumber As Integer = TextArea1.LineNumber(Position)

With a MacOS target, it works fine.
With Windows as the target, it finds Position quickly enough, but completely chokes on LineNumber(Position) - just freezes, whether free-running or single-stepping.

Is there a workaround, or a better control?

Problem is that a textarea performs all calculations starting at 0. Long documents get stupid slow.

Have you considered a control set? Too much code to include here but you can use a new textarea for each par. Ensure all have scrollbars and borders off and use another textarea as parent so it looks like it’s just a single textarea.
Use keydown event on return (Char(13) from memory) to add a new member to the set and newmember.setfocus to emulate normal paragraph breaks, coding a gap.

If you want the user to be able to scroll with the mouse wheel, drop a canvas on the top and use it’s event handling

I save each par as a database row with a column for textarea.index, so I run the search on the SQLite, returning the index, go to that single textarea and run the search there.

But why the vast difference in performance between Mac and Windows? It works fine under MacOS.

I wonder if you might be better off writing your own LineNumber method and processing the string in memory instead of relying on the control. At least for Windows.