From 40232155da35a306c29a12497630439fd715a3ae Mon Sep 17 00:00:00 2001 From: Benjamin Wolff Date: Sat, 26 Apr 2025 16:23:41 +0200 Subject: [PATCH] deduplicate search on mass-buffadd/delete --- lua/neotest/client/init.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/neotest/client/init.lua b/lua/neotest/client/init.lua index 9d600a63..b054629b 100644 --- a/lua/neotest/client/init.lua +++ b/lua/neotest/client/init.lua @@ -248,6 +248,8 @@ function neotest.Client:get_adapter(file_path) return self:_get_adapter(file_path, nil) end +local path_cache = {} + ---@async ---@param path string ---@private @@ -276,7 +278,21 @@ function neotest.Client:_update_positions(path, args) return end end + if path_cache[path] == nil then + path_cache[path] = true + vim.defer_fn(function() + path_cache[path] = nil + end, 2000) + else + logger.debug( + "Skipping search in", + path, + "for test files, because it has recently been searched" + ) + return + end logger.info("Searching", path, "for test files") + local root_path = existing_root and existing_root:data().path or path local files = lib.func_util.filter_list( adapter.is_test_file,