diff options
author | Jon Huhn <nojnhuh@users.noreply.github.com> | 2023-06-14 05:40:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 12:40:11 +0200 |
commit | 79a5b89d66db74560e751561542064674e980146 (patch) | |
tree | 1354780c69deb6cdff85c724e3a7f8bc3079459d /test/functional | |
parent | 0ce065a332cbd3874bd68a86fa9eda20c5467170 (diff) | |
download | rneovim-79a5b89d66db74560e751561542064674e980146.tar.gz rneovim-79a5b89d66db74560e751561542064674e980146.tar.bz2 rneovim-79a5b89d66db74560e751561542064674e980146.zip |
perf(lsp): reduce polling handles for workspace/didChangeWatchedFiles (#23500)
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/lua/watch_spec.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/functional/lua/watch_spec.lua b/test/functional/lua/watch_spec.lua index ad8678c17a..f041f4f1b6 100644 --- a/test/functional/lua/watch_spec.lua +++ b/test/functional/lua/watch_spec.lua @@ -107,6 +107,7 @@ describe('vim._watch', function() local result = exec_lua( [[ local root_dir = ... + local lpeg = vim.lpeg local events = {} @@ -118,7 +119,13 @@ describe('vim._watch', function() assert(vim.wait(poll_wait_ms, function() return #events == expected_events end), 'Timed out waiting for expected number of events. Current events seen so far: ' .. vim.inspect(events)) end - local stop = vim._watch.poll(root_dir, { interval = poll_interval_ms }, function(path, change_type) + local incl = lpeg.P(root_dir) * lpeg.P("/file")^-1 + local excl = lpeg.P(root_dir..'/file.unwatched') + local stop = vim._watch.poll(root_dir, { + interval = poll_interval_ms, + include_pattern = incl, + exclude_pattern = excl, + }, function(path, change_type) table.insert(events, { path = path, change_type = change_type }) end) @@ -127,12 +134,17 @@ describe('vim._watch', function() local watched_path = root_dir .. '/file' local watched, err = io.open(watched_path, 'w') assert(not err, err) + local unwatched_path = root_dir .. '/file.unwatched' + local unwatched, err = io.open(unwatched_path, 'w') + assert(not err, err) expected_events = expected_events + 2 wait_for_events() watched:close() os.remove(watched_path) + unwatched:close() + os.remove(unwatched_path) expected_events = expected_events + 2 wait_for_events() |