Zed could be an inspiration for how this works, though I have no doubt that *many* editors do it exactly like this. https://github.com/user-attachments/assets/3258eabe-88fe-45ac-8c55-f9ada2aca589