mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
[Backport release-0.9] fix(watchfiles): skip Created events when poll starts (#23197)
fix(watchfiles): skip Created events when poll starts
(cherry picked from commit 8ca1bae217
)
Co-authored-by: Jon Huhn <huhnjon@gmail.com>
This commit is contained in:
![41898282+github-actions[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
GitHub

parent
fa5fe845cc
commit
a41930bcf0
@@ -122,10 +122,6 @@ describe('vim._watch', function()
|
||||
table.insert(events, { path = path, change_type = change_type })
|
||||
end)
|
||||
|
||||
-- polling generates Created events for the existing entries when it starts.
|
||||
expected_events = expected_events + 1
|
||||
wait_for_events()
|
||||
|
||||
vim.wait(100)
|
||||
|
||||
local watched_path = root_dir .. '/file'
|
||||
@@ -158,39 +154,35 @@ describe('vim._watch', function()
|
||||
root_dir
|
||||
)
|
||||
|
||||
eq(5, #result)
|
||||
eq({
|
||||
change_type = exec_lua([[return vim._watch.FileChangeType.Created]]),
|
||||
path = root_dir,
|
||||
}, result[1])
|
||||
eq(4, #result)
|
||||
eq({
|
||||
change_type = exec_lua([[return vim._watch.FileChangeType.Created]]),
|
||||
path = root_dir .. '/file',
|
||||
}, result[2])
|
||||
}, result[1])
|
||||
eq({
|
||||
change_type = exec_lua([[return vim._watch.FileChangeType.Changed]]),
|
||||
path = root_dir,
|
||||
}, result[3])
|
||||
}, result[2])
|
||||
-- The file delete and corresponding directory change events do not happen in any
|
||||
-- particular order, so allow either
|
||||
if result[4].path == root_dir then
|
||||
if result[3].path == root_dir then
|
||||
eq({
|
||||
change_type = exec_lua([[return vim._watch.FileChangeType.Changed]]),
|
||||
path = root_dir,
|
||||
}, result[4])
|
||||
}, result[3])
|
||||
eq({
|
||||
change_type = exec_lua([[return vim._watch.FileChangeType.Deleted]]),
|
||||
path = root_dir .. '/file',
|
||||
}, result[5])
|
||||
}, result[4])
|
||||
else
|
||||
eq({
|
||||
change_type = exec_lua([[return vim._watch.FileChangeType.Deleted]]),
|
||||
path = root_dir .. '/file',
|
||||
}, result[4])
|
||||
}, result[3])
|
||||
eq({
|
||||
change_type = exec_lua([[return vim._watch.FileChangeType.Changed]]),
|
||||
path = root_dir,
|
||||
}, result[5])
|
||||
}, result[4])
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user