goto-preview icon indicating copy to clipboard operation
goto-preview copied to clipboard

[FEATURE] Closing `n+1` preview should move the focus to the `n` preview

Open D00mch opened this issue 2 years ago • 4 comments

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:

  1. Show that I commented my buffer keymap.
  2. Open project and demonstrate, that after closing second preview I didn't go to the first one;
  3. Reopen config and uncomment my close_and_move_focus_on_prev function;
  4. Open project again and demonstrate that the problem is fixed.

(my config is in fennel).

demo

D00mch avatar Dec 07 '22 07:12 D00mch

Hey 👋 that's weird. The order seems to be kept correctly for me here.

2022-12-08 11 15 04

rmagatti avatar Dec 08 '22 18:12 rmagatti

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.

D00mch avatar Dec 08 '22 20:12 D00mch

I have the same exact mapping <leader>q :q<CR> so that shouldn't be the cause.

rmagatti avatar Dec 09 '22 00:12 rmagatti

I have the same issue but I need to go three levels deep.

spocke avatar Mar 15 '23 12:03 spocke

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?

Tebro avatar Feb 16 '24 20:02 Tebro