How can I get the top line number in real time?

Hi guys,

I need to find the line number of the first line on screen, however I found that the viewport doesn’t update in real time. I have tried the lineBlockAt also, it doesn’t work with a pos which is updated in real time.

So I’m wondering how can I get that properly.

Thanks!

lineBlockAtHeight is probably what you want. Just make sure you feed it the appropriate top position (in this case, maybe -view.documentTop would work).

Thanks marijn, it works now!