You can see this in the github code viewer, where the function / class in scope stays sticky at the top.
There’s a plugin called Sticky Lines, but it’s pretty janky and does not look great. I think this is best implemented as a built in feature.
Thank you for considering it.