fix: cleanup Glance when user navigates away from list or preview
Prior to this commit it was easy ot break Glance's UI.
If you navigated out of the list or preview the Glance UI would stick around until you either close the buffer or issue another Glance preview.
Even worse, if you accidentally navigated to a new buffer while inside the list or preview window the UI breaks completely and issuing a new Glance preview does not fix things.
To fix these issues, create a new 'cleanup' autocommand which runs exactly once when the user navigates away from either the preview or list windows.
This protects against both outlined issues.
Before:
https://github.com/user-attachments/assets/8fc82ef0-dfcf-4276-8f80-73443659f5f2
After:
https://github.com/user-attachments/assets/2607391a-59de-4d76-aa5e-6f5b5fed389a
(ctrl-o issued in 'list' causes graceful close, jumping out of Glance causes graceful close)
Thank you, the idea was to use virtual lines to fill the space where glance is rendered so the preview window doesn't obstruct the code underneath and gives the ability to navigate the parent window, but virtual lines capabilities were limited at the time.
Thank you, the idea was to use virtual lines to fill the space where glance is rendered so the preview window doesn't obstruct the code underneath and gives the ability to navigate the parent window, but virtual lines capabilities were limited at the time.
I was always curious if that would work in a plugin like this. It would look very much like VScode. Its a good idea, shame it doesn't pan out in practice :(.