bug(terminal): Focus Shift to Incorrect Split After Toggling Terminal
Did you check docs and existing issues?
- [x] I have read all the snacks.nvim docs
- [x] I have updated the plugin to the latest version before submitting this issue
- [x] I have searched the existing issues of snacks.nvim
- [x] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
0.10.3
Operating system/version
Fedora Linux
Describe the bug
If I have multiple vsplits open and toggle the terminal on and then off, always the left most window is selected afterwards. It should however jump back to the previously open one.
Steps To Reproduce
-
nvim -u repro.lua - Open split
<C-w>v - Jump to right window
<C-w>l - Open terminal
:lua Snacks.terminal() - Close terminal
:lua Snacks.terminal() - Cursor now again in left window
Expected Behavior
After close the cursor goes to the position it was before opening the terminal, notably also the same window.
Repro
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{ "folke/snacks.nvim", opts = {} },
},
})
I'm seeing when I have a terminal in a split and then open any picker from the terminal window, closing the picker always selects the non-terminal split.
super annoying issue, happens to me multiple times a day every day. would be great to see this fixed
@folke any chance you could take a look at this? I tried fixing it myself yesterday but it seemed non-trivial since terminals are just reusing the win infrastructure
@folke I still see the issue here's a video of it. You can see when I'm in the terminal window and launch the picker I always end up in the other split.
https://github.com/user-attachments/assets/33d3c570-f7d9-4c2a-82f7-750a37de8d6b
@liamhennebury i was able to reproduce your problem. You may want to open another issue though, as this seems unrelated. On the latest version the problem i initially described is fixed.
That other problem with picker as well. Just update
Yep, you are right. I thought i updated it, because the other issue was gone.
But you are right. Everything works as expected now. Thank you! ❤
@folke There's seems to a difference in behaviour between close vs cancel. cancel works as expected (goes to last window) but close doesn't. For most pickers this is fine for registers I have it setup to put instead of copy. So when I'm in terminal window and try to put it inserts into the other window, because put calls close.
-
close, will put you in the main editor window. To configure this see (opts.main).- this is needed because actions will execute
-
cancel: just puts you back in the previous window