Skip to content

Commit 84e4ff5

Browse files
committed
Merge branch 'master' into feat-modified-buffers
2 parents a34c907 + e14c289 commit 84e4ff5

File tree

8 files changed

+26
-19
lines changed

8 files changed

+26
-19
lines changed

lua/nvim-tree.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,24 @@ local function setup_autocommands(opts)
362362
end
363363

364364
create_nvim_tree_autocmd("BufReadPost", {
365-
callback = function()
366-
if filters.config.filter_no_buffer or renderer.config.highlight_opened_files then
365+
callback = function(data)
366+
-- update opened file buffers
367+
if
368+
(filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none")
369+
and vim.bo[data.buf].buftype == ""
370+
then
367371
reloaders.reload_explorer()
368372
end
369373
end,
370374
})
371375

372376
create_nvim_tree_autocmd("BufUnload", {
373377
callback = function(data)
374-
if filters.config.filter_no_buffer or renderer.config.highlight_opened_files then
378+
-- update opened file buffers
379+
if
380+
(filters.config.filter_no_buffer or renderer.config.highlight_opened_files ~= "none")
381+
and vim.bo[data.buf].buftype == ""
382+
then
375383
reloaders.reload_explorer(nil, data.buf)
376384
end
377385
end,

lua/nvim-tree/actions/fs/copy-paste.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ end
132132
function M.clear_clipboard()
133133
clipboard.move = {}
134134
clipboard.copy = {}
135-
utils.notify.info "Clipboard has been emptied."
135+
notify.info "Clipboard has been emptied."
136136
end
137137

138138
function M.copy(node)

lua/nvim-tree/explorer/explore.lua

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ local explorer_node = require "nvim-tree.explorer.node"
44
local sorters = require "nvim-tree.explorer.sorters"
55
local filters = require "nvim-tree.explorer.filters"
66
local live_filter = require "nvim-tree.live-filter"
7-
local notify = require "nvim-tree.notify"
87
local log = require "nvim-tree.log"
98

109
local M = {}
@@ -46,18 +45,9 @@ local function populate_children(handle, cwd, node, git_status)
4645
end
4746
end
4847

49-
local function get_dir_handle(cwd)
50-
local handle, err = utils.fs_scandir_profiled(cwd)
51-
if err then
52-
notify.error(string.format("Failed exploring %s: %s", cwd, vim.inspect(err)))
53-
return
54-
end
55-
return handle
56-
end
57-
5848
function M.explore(node, status)
5949
local cwd = node.link_to or node.absolute_path
60-
local handle = get_dir_handle(cwd)
50+
local handle = utils.fs_scandir_profiled(cwd)
6151
if not handle then
6252
return
6353
end

lua/nvim-tree/explorer/node.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function M.node_destroy(node)
121121

122122
if node.watcher then
123123
node.watcher:destroy()
124+
node.watcher = nil
124125
end
125126
end
126127

lua/nvim-tree/explorer/reload.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ local explorer_node = require "nvim-tree.explorer.node"
44
local filters = require "nvim-tree.explorer.filters"
55
local sorters = require "nvim-tree.explorer.sorters"
66
local live_filter = require "nvim-tree.live-filter"
7-
local notify = require "nvim-tree.notify"
87
local git = require "nvim-tree.git"
98
local log = require "nvim-tree.log"
109

@@ -36,9 +35,8 @@ end
3635

3736
function M.reload(node, git_status, unloaded_bufnr)
3837
local cwd = node.link_to or node.absolute_path
39-
local handle, err = utils.fs_scandir_profiled(cwd)
40-
if err then
41-
notify.error(string.format("Failed reloading %s: %s", cwd, vim.inspect(err)))
38+
local handle = utils.fs_scandir_profiled(cwd)
39+
if not handle then
4240
return
4341
end
4442

lua/nvim-tree/explorer/watch.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ function M.create_watcher(node)
5151
local function callback(watcher)
5252
log.line("watcher", "node event scheduled refresh %s", watcher.context)
5353
utils.debounce(watcher.context, M.debounce_delay, function()
54+
if watcher.destroyed then
55+
return
56+
end
5457
if node.link_to then
5558
log.line("watcher", "node event executing refresh '%s' -> '%s'", node.link_to, node.absolute_path)
5659
else

lua/nvim-tree/git/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ function M.load_project_status(cwd)
150150
local callback = function(w)
151151
log.line("watcher", "git event scheduled '%s'", w.project_root)
152152
utils.debounce("git:watcher:" .. w.project_root, M.config.filesystem_watchers.debounce_delay, function()
153+
if w.destroyed then
154+
return
155+
end
153156
reload_tree_at(w.project_root)
154157
end)
155158
end

lua/nvim-tree/watcher.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ function Event:destroy(message)
9999
end
100100

101101
Event._events[self._path] = nil
102+
103+
self.destroyed = true
102104
end
103105

104106
function Watcher:new(path, files, callback, data)
@@ -139,6 +141,8 @@ function Watcher:destroy()
139141
self._event:remove(self._listener)
140142

141143
utils.array_remove(Watcher._watchers, self)
144+
145+
self.destroyed = true
142146
end
143147

144148
M.Watcher = Watcher

0 commit comments

Comments
 (0)