From a908daaa920373cc3b51ff2e8e3a339c33db28c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3n=C3=A1n=20Carrigan?= Date: Fri, 17 Feb 2023 08:05:23 +0000 Subject: [PATCH] fix(tree): nil check when fetching nearest See #198 --- lua/neotest/types/tree.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/neotest/types/tree.lua b/lua/neotest/types/tree.lua index 87915c52..09529ea2 100644 --- a/lua/neotest/types/tree.lua +++ b/lua/neotest/types/tree.lua @@ -176,7 +176,8 @@ end ---@param data_attr string ---@return any | nil function neotest.Tree:closest_value_for(data_attr) - return self:closest_node_with(data_attr):data()[data_attr] + local nearest = self:closest_node_with(data_attr) + return nearest and nearest:data()[data_attr] end ---@return neotest.Tree