Skip to content

Commit

Permalink
fix: g?v for comments in lua
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewferrier committed Apr 2, 2024
1 parent bb6d1c9 commit f9b9b87
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/debugprint/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ M.find_treesitter_variable = function()
return nil
else
local node_type = node:type()
local parent_node_type = node:parent():type()
local parent_node_type

if node:parent() ~= nil then
-- This check is necessary; it triggers for example in comments in
-- lua code
parent_node_type = node:parent():type()
end

local variable_name

Expand Down
19 changes: 19 additions & 0 deletions tests/debugprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,25 @@ if vim.fn.has("nvim-0.9.0") == 1 then
"</html>",
})
end)

it("comment in lua", function()
local filename = init_file({
"x = 3",
"-- abc",
"a = 2",
}, "lua", 2, 4)

feedkeys("g?v<CR>")

check_lines({
"x = 3",
"-- abc",
"print('DEBUGPRINT[1]: "
.. filename
.. ":2: abc=' .. vim.inspect(abc))",
"a = 2",
})
end)
end)
end

Expand Down

0 comments on commit f9b9b87

Please sign in to comment.