fix(#1731 #1723 #1716): handle all external file system changes (#1757)

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

* fix(#1731): reload explorer reloads closed folders

* fix(#1731): do not fire folder created event on file create

* fix(#1731): reload profile absolute path, not link to

* fix(#1731): find-file locks/profiles on real path, reloads when watchers disabled

* Revert "fix(#1731): reload explorer reloads closed folders"

This reverts commit 5dfd8bd2fa.

* fix(#1731): tidy watch reload

* fix(#1731): move refresh_node from watch to reload

* fix(#1731): find-file reloads all nodes for the containing directory

* fix(#1731): create-file refreshes synchronously

* fix(#1731): remove unused watch node

* fix(#1731): find-file refreshes root

* fix(#1716): create-file invokes find-file

* fix(#1731): refresh path walks down the tree to the targedt
This commit is contained in:
Alexander Courtis
2022-11-26 14:19:09 +11:00
committed by GitHub
parent 99d713644d
commit b17358ff4d
6 changed files with 129 additions and 61 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