File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,13 @@ M.find_treesitter_variable = function()
127
127
return nil
128
128
else
129
129
local node_type = node :type ()
130
- local parent_node_type = node :parent ():type ()
130
+ local parent_node_type
131
+
132
+ if node :parent () ~= nil then
133
+ -- This check is necessary; it triggers for example in comments in
134
+ -- lua code
135
+ parent_node_type = node :parent ():type ()
136
+ end
131
137
132
138
local variable_name
133
139
Original file line number Diff line number Diff line change @@ -1637,6 +1637,25 @@ if vim.fn.has("nvim-0.9.0") == 1 then
1637
1637
" </html>" ,
1638
1638
})
1639
1639
end )
1640
+
1641
+ it (" comment in lua" , function ()
1642
+ local filename = init_file ({
1643
+ " x = 3" ,
1644
+ " -- abc" ,
1645
+ " a = 2" ,
1646
+ }, " lua" , 2 , 4 )
1647
+
1648
+ feedkeys (" g?v<CR>" )
1649
+
1650
+ check_lines ({
1651
+ " x = 3" ,
1652
+ " -- abc" ,
1653
+ " print('DEBUGPRINT[1]: "
1654
+ .. filename
1655
+ .. " :2: abc=' .. vim.inspect(abc))" ,
1656
+ " a = 2" ,
1657
+ })
1658
+ end )
1640
1659
end )
1641
1660
end
1642
1661
You can’t perform that action at this time.
0 commit comments