mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
Merge pull request #13449 from nvim-treesitter/fix-language-for-range
fix(treesitter): incorrect method name call
This commit is contained in:
commit
5855a3ea7b
@ -445,7 +445,7 @@ end
|
||||
function LanguageTree:language_for_range(range)
|
||||
for _, child in pairs(self._children) do
|
||||
if child:contains(range) then
|
||||
return child:node_for_range(range)
|
||||
return child:language_for_range(range)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -919,4 +919,25 @@ local hl_query = [[
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("when getting the language for a range", function()
|
||||
before_each(function()
|
||||
insert([[
|
||||
int x = INT_MAX;
|
||||
#define VALUE 123456789
|
||||
]])
|
||||
end)
|
||||
|
||||
it("should return the correct language tree", function()
|
||||
local result = exec_lua([[
|
||||
parser = vim.treesitter.get_parser(0, "c", {
|
||||
queries = { c = "(preproc_def (preproc_arg) @c)"}})
|
||||
|
||||
local sub_tree = parser:language_for_range({1, 18, 1, 19})
|
||||
|
||||
return sub_tree == parser:children().c
|
||||
]])
|
||||
|
||||
eq(result, true)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user