A lightweight programming environment for desktop and mobile devices

bugfix: position cursor after dragging scrollbar

scenario: drag the editor scrollbar down more than a page tap near the bottom of the editor. Tapping works tap near the top of the editor. Nothing happens.

The cause: as you drag the scrollbar, starty gets set for lines on screen. However, the lines going above the screen don't get their starty reset.

Why even would any tapping work? Answer: dragging the scrollbar is always contiguous, never random access. So when you drag a little bit, the top line gets its starty set. When you drag a little more the next line has its starty set. As a result, the usual pattern with the bug was something like: line 1: 30 line 2: 60 line 3: 90 line 4: 30 line 5: 30 line 6: 30 line 7: 30 line 8: 30 …

As a result, low ys (<90 in this made-up example) get caught in those first few lines, but high ys get to the right line below.

Root cause: any time you scroll, you have to call Text.redraw_all. That will cause startys to look like this:

line 1: nil line 2: nil line 3: nil line 4: nil line 5: nil line 6: 30 <== screen_top1 line 7: 60 …

Created by  akkartik  on December 2, 2023
KVCVI4YFAYOVHCZRJYBQ7CJWUVMUDTUBHNFWW5V7EIEYNPR6FJDAC
Change contents