@@ -23,6 +23,27 @@ M.get_open_buffers = function(state)
2323 context .folders [root .path ] = root
2424 local terminals = {}
2525
26+ local function add_buffer (bufnr , path )
27+ local is_loaded = vim .api .nvim_buf_is_loaded (bufnr )
28+ if is_loaded or state .show_unloaded then
29+ local is_listed = vim .fn .buflisted (bufnr )
30+ if is_listed == 1 then
31+ if path == " " then
32+ path = " [No Name]"
33+ end
34+ local success , item = pcall (file_items .create_item , context , path , " file" , bufnr )
35+ if success then
36+ item .extra = {
37+ bufnr = bufnr ,
38+ is_listed = is_listed ,
39+ }
40+ else
41+ log .error (" Error creating item for " .. path .. " : " .. item )
42+ end
43+ end
44+ end
45+ end
46+
2647 local bufs = vim .api .nvim_list_bufs ()
2748 for _ , b in ipairs (bufs ) do
2849 local path = vim .api .nvim_buf_get_name (b )
@@ -45,25 +66,17 @@ M.get_open_buffers = function(state)
4566 if utils .is_subpath (state .path , abs_path ) then
4667 table.insert (terminals , item )
4768 end
69+ elseif path == " " then
70+ add_buffer (b , path )
4871 else
49- local rootsub = path :sub (1 , # state .path )
50- -- make sure this is within the root path
51- if rootsub == state .path then
52- local is_loaded = vim .api .nvim_buf_is_loaded (b )
53- if is_loaded or state .show_unloaded then
54- local is_listed = vim .fn .buflisted (b )
55- if is_listed == 1 then
56- local success , item = pcall (file_items .create_item , context , path , " file" )
57- if success then
58- item .extra = {
59- bufnr = b ,
60- is_listed = is_listed ,
61- }
62- else
63- log .error (" Error creating item for " .. path .. " : " .. item )
64- end
65- end
72+ if # state .path > 1 then
73+ local rootsub = path :sub (1 , # state .path )
74+ -- make sure this is within the root path
75+ if rootsub == state .path then
76+ add_buffer (b , path )
6677 end
78+ else
79+ add_buffer (b , path )
6780 end
6881 end
6982 end
0 commit comments