fix: buffer selection logic to include all listed buffers (#1742)

This commit is contained in:
kyrisu
2025-03-27 15:15:14 +00:00
committed by GitHub
parent cd13eeb7d9
commit cfc5a78813

View File

@@ -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