#1228 close moves focus to previous win on current tab (#1235)

This commit is contained in:
Alexander Courtis 2022-05-07 19:26:22 +10:00 committed by GitHub
parent d54fc28045
commit 543c07aa7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,6 @@ local tabinitial = {
}
local BUFNR_PER_TAB = {}
local LAST_FOCUSED_WIN = nil
local BUFFER_OPTIONS = {
swapfile = false,
buftype = "nofile",
@ -174,8 +173,9 @@ function M.close()
for _, win in pairs(a.nvim_list_wins()) do
if tree_win ~= win and a.nvim_win_get_config(win).relative == "" then
a.nvim_win_close(tree_win, true)
if tree_win == current_win and LAST_FOCUSED_WIN then
a.nvim_set_current_win(LAST_FOCUSED_WIN)
local prev_win = vim.fn.winnr "#" -- this tab only
if tree_win == current_win and prev_win > 0 then
a.nvim_set_current_win(vim.fn.win_getid(prev_win))
end
events._dispatch_on_tree_close()
return
@ -188,7 +188,6 @@ function M.open(options)
return
end
LAST_FOCUSED_WIN = a.nvim_get_current_win()
create_buffer()
open_window()
set_window_options_and_buffer()