Skip to content

Commit 65eed44

Browse files
authored
fix: move window when goto another tabpage (#304)
1 parent 82404b1 commit 65eed44

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

lua/fidget/notification/window.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,20 @@ function M.get_window(row, col, anchor, relative, width, height)
471471
height = math.min(height, M.options.max_height)
472472
end
473473

474-
if state.window_id == nil or not vim.api.nvim_win_is_valid(state.window_id) then
474+
local valid = state.window_id and vim.api.nvim_win_is_valid(state.window_id)
475+
476+
-- Window exists but is in a different tabpage
477+
if valid
478+
and vim.api.nvim_win_get_tabpage(state.window_id) ~= vim.api.nvim_get_current_tabpage()
479+
and not pcall(vim.api.nvim_win_set_config, state.window_id, { win = vim.api.nvim_get_current_win() })
480+
then
481+
-- manually close and so recreate before https://github.com/neovim/neovim/pull/35816
482+
vim.api.nvim_win_close(state.window_id, true)
483+
valid = nil
484+
state.window_id = nil
485+
end
486+
487+
if not valid then
475488
-- Create window to display notifications buffer, but don't enter (2nd param)
476489
state.window_id = vim.api.nvim_open_win(M.get_buffer(), false, {
477490
relative = relative,

0 commit comments

Comments
 (0)