mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
fix(treesitter): properly clip nested injections
This commit is contained in:
committed by
Lewis Russell
parent
a59b052857
commit
baabc35987
@@ -897,7 +897,7 @@ local function clip_regions(region1, region2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Advance the range that ends earlier
|
-- Advance the range that ends earlier
|
||||||
if Range.cmp_pos.le(r1[3], r1[4], r2[3], r2[4]) then
|
if Range.cmp_pos.le(r1[4], r1[5], r2[4], r2[5]) then
|
||||||
i = i + 1
|
i = i + 1
|
||||||
else
|
else
|
||||||
j = j + 1
|
j = j + 1
|
||||||
|
|||||||
@@ -854,6 +854,35 @@ int x = INT_MAX;
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('properly clips nested injections #34098', function()
|
||||||
|
insert([=[
|
||||||
|
```lua
|
||||||
|
vim.cmd([[
|
||||||
|
set noswapfile
|
||||||
|
set noswapfile
|
||||||
|
set noswapfile
|
||||||
|
]])
|
||||||
|
```
|
||||||
|
]=])
|
||||||
|
|
||||||
|
local result = exec_lua(function()
|
||||||
|
local parser = vim.treesitter.get_parser(0, 'markdown')
|
||||||
|
parser:parse(true)
|
||||||
|
|
||||||
|
return parser._children.lua._children.vim:included_regions()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local expected = {
|
||||||
|
{
|
||||||
|
{ 1, 10, 17, 2, 0, 18 },
|
||||||
|
{ 2, 0, 18, 3, 0, 33 },
|
||||||
|
{ 3, 0, 33, 4, 0, 48 },
|
||||||
|
{ 4, 0, 48, 5, 0, 63 },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
eq(expected, result)
|
||||||
|
end)
|
||||||
|
|
||||||
describe('when getting the language for a range', function()
|
describe('when getting the language for a range', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
insert([[
|
insert([[
|
||||||
|
|||||||
Reference in New Issue
Block a user