goolord / alpha-nvim

a lua powered greeter like vim-startify / dashboard-nvim
MIT License
1.73k stars 101 forks source link

fix: redraw terminal elements on subsequent Alpha redraws #282

Open bezhermoso opened 1 month ago

bezhermoso commented 1 month ago

The alpha.term extension deletes the terminal buffer on AlphaClosed, which causes an Invalid window id: ... error when the plugin tries to redraw things. This PR makes it so that it sets the redraw option back to true when the Alpha buffer is closed. Doing it this way still avoids the infinite redraw problem that this flag was preventing.

This should solve the issue reported here: https://github.com/goolord/alpha-nvim/issues/275

goolord commented 1 month ago

ah, i see the problem now, but i'm pretty sure this is like using a shotgun to kill a fly. the terminal buffer should just get redrawn when you open alpha back up

bezhermoso commented 1 month ago

@goolord I've found that something spams the WinResized event whenever Alpha opens back up a second time, which cause Alpha to redraw over & over & over again because of this autocmd.

I cannot figure out what's causing the deluge of WinResized events though. Any ideas?

bezhermoso commented 1 month ago

Hmm, if I disable the terminal element, then the event no longer spams. So it could be something in what the terminal element does that causes its own issue...

bezhermoso commented 1 month ago

Hi @goolord, can you please expound on the terminal buffer should just get redrawn when you open alpha back up?

Isn't this what this PR achieves? The opt.redraw = false rightfully prevents the terminal from rerunning again during window resizes while Alpha is open, for example. In such cases the element is simply repositioned. This PR marks the element to be redrawn the next time Alpha is opened. Am I misunderstanding your ask?