mirror of
https://github.com/neovim/neovim
synced 2025-07-18 10:11:50 +00:00
perf(lsp): use async fs_stat for file watching on linux (#26123)
This commit is contained in:
committed by
GitHub
parent
e89071522c
commit
7e97c773e3
@ -132,35 +132,36 @@ local function recurse_watch(path, opts, callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
for fullpath, events_list in pairs(filechanges) do
|
for fullpath, events_list in pairs(filechanges) do
|
||||||
local stat = uv.fs_stat(fullpath)
|
uv.fs_stat(fullpath, function(_, stat)
|
||||||
---@type vim._watch.FileChangeType
|
---@type vim._watch.FileChangeType
|
||||||
local change_type
|
local change_type
|
||||||
if stat then
|
if stat then
|
||||||
change_type = FileChangeType.Created
|
change_type = FileChangeType.Created
|
||||||
for _, event in ipairs(events_list) do
|
for _, event in ipairs(events_list) do
|
||||||
if event.change then
|
if event.change then
|
||||||
change_type = FileChangeType.Changed
|
change_type = FileChangeType.Changed
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
if stat.type == 'directory' then
|
||||||
if stat.type == 'directory' then
|
local handle = handles[fullpath]
|
||||||
|
if not handle then
|
||||||
|
handle = assert(uv.new_fs_event())
|
||||||
|
handles[fullpath] = handle
|
||||||
|
handle:start(fullpath, uvflags, create_on_change(fullpath))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
local handle = handles[fullpath]
|
local handle = handles[fullpath]
|
||||||
if not handle then
|
if handle then
|
||||||
handle = assert(uv.new_fs_event())
|
if not handle:is_closing() then
|
||||||
handles[fullpath] = handle
|
handle:close()
|
||||||
handle:start(fullpath, uvflags, create_on_change(fullpath))
|
end
|
||||||
|
handles[fullpath] = nil
|
||||||
end
|
end
|
||||||
|
change_type = FileChangeType.Deleted
|
||||||
end
|
end
|
||||||
else
|
callback(fullpath, change_type)
|
||||||
local handle = handles[fullpath]
|
end)
|
||||||
if handle then
|
|
||||||
if not handle:is_closing() then
|
|
||||||
handle:close()
|
|
||||||
end
|
|
||||||
handles[fullpath] = nil
|
|
||||||
end
|
|
||||||
change_type = FileChangeType.Deleted
|
|
||||||
end
|
|
||||||
callback(fullpath, change_type)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local root_handle = assert(uv.new_fs_event())
|
local root_handle = assert(uv.new_fs_event())
|
||||||
|
Reference in New Issue
Block a user