fix(#1731): watcher refreshes node rather than the first node matching absolute path, profile refresh

This commit is contained in:
Alexander Courtis
2022-11-19 17:07:05 +11:00
parent e38e061710
commit 1c57a8284d
5 changed files with 57 additions and 23 deletions

View File

@@ -10,7 +10,7 @@ function M.folder(parent, absolute_path, name)
local handle = vim.loop.fs_scandir(absolute_path)
local has_children = handle and vim.loop.fs_scandir_next(handle) ~= nil
return {
local node = {
type = "directory",
absolute_path = absolute_path,
fs_stat = vim.loop.fs_stat(absolute_path),
@@ -20,8 +20,11 @@ function M.folder(parent, absolute_path, name)
nodes = {},
open = false,
parent = parent,
watcher = watch.create_watcher(absolute_path),
}
node.watcher = watch.create_watcher(node)
return node
end
function M.is_executable(parent, absolute_path, ext)
@@ -63,16 +66,18 @@ end
function M.link(parent, absolute_path, name)
--- I dont know if this is needed, because in my understanding, there isn't hard links in windows, but just to be sure i changed it.
local link_to = vim.loop.fs_realpath(absolute_path)
local open, nodes, has_children, watcher
if (link_to ~= nil) and vim.loop.fs_stat(link_to).type == "directory" then
local open, nodes, has_children
local is_dir_link = (link_to ~= nil) and vim.loop.fs_stat(link_to).type == "directory"
if is_dir_link then
local handle = vim.loop.fs_scandir(link_to)
has_children = handle and vim.loop.fs_scandir_next(handle) ~= nil
open = false
nodes = {}
watcher = watch.create_watcher(link_to)
end
return {
local node = {
type = "link",
absolute_path = absolute_path,
fs_stat = vim.loop.fs_stat(absolute_path),
@@ -83,8 +88,13 @@ function M.link(parent, absolute_path, name)
nodes = nodes,
open = open,
parent = parent,
watcher = watcher,
}
if is_dir_link then
node.watcher = watch.create_watcher(node)
end
return node
end
return M