refactor(sidebar): get rid of winids table, use containers table

Now that we have a table listing all containers and can iterate over it
we no longer need a separate table with window IDs that we need to
maintain. Remove it.
This commit is contained in:
Dmitry Torokhov
2025-07-19 17:48:13 -07:00
committed by yetone
parent 7d60b51324
commit beeea5cb1c
2 changed files with 109 additions and 90 deletions

View File

@@ -190,17 +190,15 @@ function M:open()
vim.keymap.set("n", Config.mappings.confirm.resp, function()
local sidebar = require("avante").get()
if not sidebar then return end
if sidebar.winids.result_container and vim.api.nvim_win_is_valid(sidebar.winids.result_container) then
vim.api.nvim_set_current_win(sidebar.winids.result_container)
if sidebar and sidebar.containers.result and vim.api.nvim_win_is_valid(sidebar.containers.result.winid) then
vim.api.nvim_set_current_win(sidebar.containers.result.winid)
end
end, { buffer = popup.bufnr, nowait = true })
vim.keymap.set("n", Config.mappings.confirm.input, function()
local sidebar = require("avante").get()
if not sidebar then return end
if sidebar.winids.input_container and vim.api.nvim_win_is_valid(sidebar.winids.input_container) then
vim.api.nvim_set_current_win(sidebar.winids.input_container)
if sidebar and sidebar.containers.input and vim.api.nvim_win_is_valid(sidebar.containers.input.winid) then
vim.api.nvim_set_current_win(sidebar.containers.input.winid)
end
end, { buffer = popup.bufnr, nowait = true })