From cfc5a78813909a1aa2c25ec7f1d8d37f078f60da Mon Sep 17 00:00:00 2001 From: kyrisu Date: Thu, 27 Mar 2025 15:15:14 +0000 Subject: [PATCH] fix: buffer selection logic to include all listed buffers (#1742) --- lua/avante/file_selector.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/avante/file_selector.lua b/lua/avante/file_selector.lua index 99440b8..f26e505 100644 --- a/lua/avante/file_selector.lua +++ b/lua/avante/file_selector.lua @@ -421,9 +421,11 @@ end function FileSelector:add_buffer_files() local buffers = vim.api.nvim_list_bufs() for _, bufnr in ipairs(buffers) do - if vim.api.nvim_buf_is_loaded(bufnr) then + -- Skip invalid or unlisted buffers + if vim.api.nvim_buf_is_valid(bufnr) and vim.bo[bufnr].buflisted then local filepath = vim.api.nvim_buf_get_name(bufnr) - if filepath and filepath ~= "" and not has_scheme(filepath) then + -- Skip empty paths and special buffers (like terminals) + if filepath ~= "" and not has_scheme(filepath) then local relative_path = Utils.relative_path(filepath) self:add_selected_file(relative_path) end