@@ -101,10 +101,19 @@ function Explorer:create_autocmds()
101101 vim .api .nvim_create_autocmd (" BufReadPost" , {
102102 group = self .augroup_id ,
103103 callback = function (data )
104- if (self .filters .state .no_buffer or self .opts .renderer .highlight_opened_files ~= " none" ) and vim .bo [data .buf ].buftype == " " then
104+ -- only handle normal files
105+ if vim .bo [data .buf ].buftype ~= " " then
106+ return
107+ end
108+
109+ if self .filters .state .no_buffer then
110+ -- full reload to update the filter state
105111 utils .debounce (" Buf:filter_buffer_" .. self .uid_explorer , self .opts .view .debounce_delay , function ()
106112 self :reload_explorer ()
107113 end )
114+ elseif self .opts .renderer .highlight_opened_files ~= " none" then
115+ -- draw to update opened highlight
116+ self .renderer :draw ()
108117 end
109118 end ,
110119 })
@@ -113,10 +122,21 @@ function Explorer:create_autocmds()
113122 vim .api .nvim_create_autocmd (" BufUnload" , {
114123 group = self .augroup_id ,
115124 callback = function (data )
116- if (self .filters .state .no_buffer or self .opts .renderer .highlight_opened_files ~= " none" ) and vim .bo [data .buf ].buftype == " " then
125+ -- only handle normal files
126+ if vim .bo [data .buf ].buftype ~= " " then
127+ return
128+ end
129+
130+ if self .filters .state .no_buffer then
131+ -- full reload to update the filter state
117132 utils .debounce (" Buf:filter_buffer_" .. self .uid_explorer , self .opts .view .debounce_delay , function ()
118133 self :reload_explorer ()
119134 end )
135+ elseif self .opts .renderer .highlight_opened_files ~= " none" then
136+ -- draw to update opened highlight; must be delayed as the buffer is still loaded during BufUnload
137+ utils .debounce (" Buf:highlight_opened_files_" .. self .uid_explorer , self .opts .view .debounce_delay , function ()
138+ self .renderer :draw ()
139+ end )
120140 end
121141 end ,
122142 })
0 commit comments