kdheepak / lazygit.nvim

Plugin for calling lazygit from within neovim.
MIT License
1.47k stars 53 forks source link

fix: open_floating_window should return lazygit buffer instead of border_window #103

Closed gmerzu closed 1 year ago

gmerzu commented 1 year ago

The function open_floating_window returns win, border_window, what is incorrect. As result, in callback on_exit, vim.api.nvim_buf_is_valid(buffer) is false, and LazyGit terminal buffer persists as orphan (and hidden) with text [Process exited 0].

Every time LazyGit exits, an orphan terminal buffer remains , which can be checked, e.g. in Neo-tree:

term://~/.config/nvim//4010044:lazygit #3
term://~/.config/nvim//4010053:lazygit #7
...

This PR provides a fix to return LAZYGIT_BUFFER instead of border_window, so that the behavior is correct with no issues on my side.

In fact, it is not clear for me, why LAZYGIT_BUFFER is present, it is always set to nil in on_exit callback, probably some refactoring is required to remove LAZYGIT_BUFFER and LAZYGIT_LOADED and use local variables for corresponding buffer.

kdheepak commented 1 year ago

I believe it was used in old code, but after a few PRs by contributors it wasn't required any more. I need to look into this and do the refactoring as you mentioned.