Skip to content

Commit

Permalink
fix: Get node name correctly for default case
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewferrier committed Apr 28, 2024
1 parent 14b666f commit 1c93860
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/debugprint/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ M.find_treesitter_variable = function(filetype_config)
if vim.tbl_get(filetype_config, "find_treesitter_variable") then
return filetype_config.find_treesitter_variable(obj)
else
return obj.node_text
return obj.get_node_text(obj.node)
end
end
end
Expand Down
17 changes: 17 additions & 0 deletions tests/debugprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,23 @@ describe("can handle treesitter identifiers", function()

assert.are.same(vim.api.nvim_win_get_cursor(0), { 2, 4 })
end)

it("non-special case variable (python)", function()
debugprint.setup()

local filename = init_file({
"x = 1",
}, "py", 1, 0)

feedkeys("g?v")

check_lines({
"x = 1",
'print(f"DEBUGPRINT[1]: ' .. filename .. ':1: x={x}")',
})

assert.are.same(vim.api.nvim_win_get_cursor(0), { 1, 0 })
end)
end)

describe("visual selection", function()
Expand Down

0 comments on commit 1c93860

Please sign in to comment.