goto-preview
goto-preview copied to clipboard
[FEATURE] Closing `n+1` preview should move the focus to the `n` preview
Describe the solution you'd like
If I open previews a
,b
, and c
, closing c
should put my focus on b; closing b — on a
.
Describe alternatives you've considered
I have a function that I dovim.keymap.set
with the local buffer inside the post_open_hook
:
local function close_and_move_focus_on_prev()
local prev_win = vim.fn.winnr()
vim.cmd("wincmd p")
return vim.cmd((prev_win .. "wincmd q"))
end
Additional context On the gif below I do:
- Show that I commented my buffer keymap.
- Open project and demonstrate, that after closing second preview I didn't go to the first one;
- Reopen config and uncomment my
close_and_move_focus_on_prev
function; - Open project again and demonstrate that the problem is fixed.
(my config is in fennel).
Hey 👋 that's weird. The order seems to be kept correctly for me here.
I close windows with mapping that does :q<Cr>
. Don't know what may cause this behavior. Lets maybe wait for a while if anyone has the same problem.
I have the same exact mapping <leader>q :q<CR>
so that shouldn't be the cause.
I have the same issue but I need to go three levels deep.
Same issue here, if using <C-w>c
it doesn't go back at all, if you chain three deep then :q
will only go back once. I guess there is a variable last
that gets updated instead of a stack?