File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,9 @@ M.View = {
68
68
--- Find a rogue NvimTree buffer that might have been spawned by i.e. a session.
69
69
--- @return integer | nil
70
70
local function find_rogue_buffer ()
71
- for i = 1 , vim . fn . bufnr ( " $ " ), 1 do
72
- if vim .fn .bufname (i ) == " NvimTree" then
73
- return i
71
+ for _ , v in ipairs ( a . nvim_list_bufs ()) do
72
+ if vim .fn .bufname (v ) == " NvimTree" then
73
+ return v
74
74
end
75
75
end
76
76
return nil
@@ -89,9 +89,14 @@ function M._wipe_rogue_buffer()
89
89
if bn then
90
90
local win_ids = vim .fn .win_findbuf (bn )
91
91
for _ , id in ipairs (win_ids ) do
92
- a .nvim_win_close (id , true )
92
+ if vim .fn .win_gettype (id ) ~= " autocmd" then
93
+ a .nvim_win_close (id , true )
94
+ end
93
95
end
94
- a .nvim_buf_delete (bn , {})
96
+
97
+ vim .schedule (function ()
98
+ pcall (a .nvim_buf_delete , bn , {})
99
+ end )
95
100
end
96
101
end
97
102
You can’t perform that action at this time.
0 commit comments