Skip to content

Commit

Permalink
fix(tree): nil check when fetching nearest
Browse files Browse the repository at this point in the history
See #198
  • Loading branch information
rcarriga committed Feb 17, 2023
1 parent 8807379 commit a908daa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/neotest/types/tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a908daa

Please sign in to comment.