Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/telescope.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,8 @@ builtin.buffers({opts}) *telescope.builtin.buffers()*
{cwd} (string) specify a working directory to
filter buffers list by
{show_all_buffers} (boolean) if true, show all buffers,
including unloaded buffers
including unloaded buffers and
unlisted buffers
(default: true)
{ignore_current_buffer} (boolean) if true, don't show the current
buffer in the list (default:
Expand Down
16 changes: 10 additions & 6 deletions lua/telescope/builtin/__internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -926,13 +926,17 @@ internal.buffers = function(opts)
opts = apply_cwd_only_aliases(opts)

local bufnrs = vim.tbl_filter(function(bufnr)
if 1 ~= vim.fn.buflisted(bufnr) then
return false
end
-- only hide unloaded buffers if opts.show_all_buffers is false, keep them listed if true or nil
if opts.show_all_buffers == false and not api.nvim_buf_is_loaded(bufnr) then
return false
-- only hide unlisted and unloaded buffers if opts.show_all_buffers is
-- false, keep them listed if true or nil
if opts.show_all_buffers == false then
if 1 ~= vim.fn.buflisted(bufnr) then
return false
end
if not api.nvim_buf_is_loaded(bufnr) then
return false
end
end

if opts.ignore_current_buffer and bufnr == api.nvim_get_current_buf() then
return false
end
Expand Down
Loading