@@ -101,10 +101,19 @@ function Explorer:create_autocmds()
101
101
vim .api .nvim_create_autocmd (" BufReadPost" , {
102
102
group = self .augroup_id ,
103
103
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
105
111
utils .debounce (" Buf:filter_buffer_" .. self .uid_explorer , self .opts .view .debounce_delay , function ()
106
112
self :reload_explorer ()
107
113
end )
114
+ elseif self .opts .renderer .highlight_opened_files ~= " none" then
115
+ -- draw to update opened highlight
116
+ self .renderer :draw ()
108
117
end
109
118
end ,
110
119
})
@@ -113,10 +122,21 @@ function Explorer:create_autocmds()
113
122
vim .api .nvim_create_autocmd (" BufUnload" , {
114
123
group = self .augroup_id ,
115
124
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
117
132
utils .debounce (" Buf:filter_buffer_" .. self .uid_explorer , self .opts .view .debounce_delay , function ()
118
133
self :reload_explorer ()
119
134
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 )
120
140
end
121
141
end ,
122
142
})
0 commit comments