How do you iterate over visible editor lines?

The editor is from line 1 to line 50.
Currently, the cursor is at 36 and what I can see is partially line 33 all the way up to line 47.

I have tried view.viewportLineBlocks() but it seems to yield all line blocks instead of the ones currently in screen. Am I perhaps using it wrong?

Thanks for the help.

You should be able to use lineBlockAtHeight to find the lines at the top and bottom of the scrollable element.

1 Like