From 1c938607af581a6ecc850850a51c0f5526c53032 Mon Sep 17 00:00:00 2001 From: Andrew Ferrier <107015+andrewferrier@users.noreply.github.com> Date: Sun, 28 Apr 2024 09:57:01 +0100 Subject: [PATCH] fix: Get node name correctly for default case --- lua/debugprint/utils.lua | 2 +- tests/debugprint.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lua/debugprint/utils.lua b/lua/debugprint/utils.lua index 7347645..2520386 100644 --- a/lua/debugprint/utils.lua +++ b/lua/debugprint/utils.lua @@ -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 diff --git a/tests/debugprint.lua b/tests/debugprint.lua index e4b49c6..e352bf4 100644 --- a/tests/debugprint.lua +++ b/tests/debugprint.lua @@ -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()