Skip to content

Commit

Permalink
fix: Handle not finding node
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ferrier committed Aug 12, 2022
1 parent 1474cae commit d4e4355
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lua/debugprint/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,18 @@ local find_treesitter_variable = function()
-- Once get_node_at_cursor() is in NeoVim core, the nvim-treesitter
-- dependency can be removed: https://github.com/neovim/neovim/pull/18232
local node = ts_utils.get_node_at_cursor()
local node_type = node:type()
local variable_name = vim.treesitter.query.get_node_text(node, 0)

if node_type ~= "identifier" then
if node == nil then
return nil
else
return variable_name
local node_type = node:type()
local variable_name = vim.treesitter.query.get_node_text(node, 0)

if node_type ~= "identifier" then
return nil
else
return variable_name
end
end
end
end
Expand Down

0 comments on commit d4e4355

Please sign in to comment.