Skip to content

Commit 2484721

Browse files
committed
builtin.buffers: show_all_buffers should also apply to unlisted buffers
1 parent 5255aa2 commit 2484721

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

doc/telescope.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,8 @@ builtin.buffers({opts}) *telescope.builtin.buffers()*
14541454
{cwd} (string) specify a working directory to
14551455
filter buffers list by
14561456
{show_all_buffers} (boolean) if true, show all buffers,
1457-
including unloaded buffers
1457+
including unloaded buffers and
1458+
unlisted buffers
14581459
(default: true)
14591460
{ignore_current_buffer} (boolean) if true, don't show the current
14601461
buffer in the list (default:

lua/telescope/builtin/__internal.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,17 @@ internal.buffers = function(opts)
926926
opts = apply_cwd_only_aliases(opts)
927927

928928
local bufnrs = vim.tbl_filter(function(bufnr)
929-
if 1 ~= vim.fn.buflisted(bufnr) then
930-
return false
931-
end
932-
-- only hide unloaded buffers if opts.show_all_buffers is false, keep them listed if true or nil
933-
if opts.show_all_buffers == false and not api.nvim_buf_is_loaded(bufnr) then
934-
return false
929+
-- only hide unlisted and unloaded buffers if opts.show_all_buffers is
930+
-- false, keep them listed if true or nil
931+
if opts.show_all_buffers == false then
932+
if 1 ~= vim.fn.buflisted(bufnr) then
933+
return false
934+
end
935+
if not api.nvim_buf_is_loaded(bufnr) then
936+
return false
937+
end
935938
end
939+
936940
if opts.ignore_current_buffer and bufnr == api.nvim_get_current_buf() then
937941
return false
938942
end

0 commit comments

Comments
 (0)