mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
fix(win): better way of finding a main window when fixbuf is true
This commit is contained in:
parent
2ff8ce0208
commit
84ee7ddf54
1 changed files with 15 additions and 8 deletions
|
@ -810,17 +810,24 @@ function M:show()
|
||||||
|
|
||||||
-- another buffer was opened in this window
|
-- another buffer was opened in this window
|
||||||
-- find another window to swap with
|
-- find another window to swap with
|
||||||
|
local main ---@type number?
|
||||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
if win ~= self.win and vim.bo[vim.api.nvim_win_get_buf(win)].buftype == "" then
|
local is_float = vim.api.nvim_win_get_config(win).relative ~= ""
|
||||||
vim.schedule(function()
|
if not is_float then
|
||||||
vim.api.nvim_win_set_buf(self.win, self.buf)
|
main = win
|
||||||
vim.api.nvim_win_set_buf(win, buf)
|
if win ~= self.win and vim.bo[vim.api.nvim_win_get_buf(win)].buftype == "" then
|
||||||
vim.api.nvim_set_current_win(win)
|
break
|
||||||
vim.cmd.stopinsert()
|
end
|
||||||
end)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if main then
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.api.nvim_win_set_buf(self.win, self.buf)
|
||||||
|
vim.api.nvim_win_set_buf(main, buf)
|
||||||
|
vim.api.nvim_set_current_win(main)
|
||||||
|
vim.cmd.stopinsert()
|
||||||
|
end)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue