aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2025-03-28 04:38:47 -0700
committerGitHub <noreply@github.com>2025-03-28 04:38:47 -0700
commit75cbd9a8aeb2fb0f7efb5fca6a2d42097810a95e (patch)
tree25413df4c75a93ec91f9c40162688685fab788b0 /test
parent18fa61049a9e19a3e8cbac73d963ac1dac251b39 (diff)
downloadrneovim-75cbd9a8aeb2fb0f7efb5fca6a2d42097810a95e.tar.gz
rneovim-75cbd9a8aeb2fb0f7efb5fca6a2d42097810a95e.tar.bz2
rneovim-75cbd9a8aeb2fb0f7efb5fca6a2d42097810a95e.zip
refactor(treesitter): simplify injection retrieval #33104
Simplify the logic for retrieving the injection ranges for the language tree. The trees are now also sorted by starting position, regardless of whether they are part of a combined injection or not. This would be helpful if ranges are ever to be stored in an interval tree or other kind of sorted tree structure.
Diffstat (limited to 'test')
-rw-r--r--test/functional/treesitter/parser_spec.lua34
1 files changed, 17 insertions, 17 deletions
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index b348f77b38..510eacb958 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -575,22 +575,22 @@ int x = INT_MAX;
eq(5, exec_lua('return #parser:children().c:trees()'))
eq({
{ 0, 0, 7, 0 }, -- root tree
+ { 1, 26, 1, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
{ 3, 14, 3, 17 }, -- VALUE 123
{ 4, 15, 4, 18 }, -- VALUE1 123
{ 5, 15, 5, 18 }, -- VALUE2 123
- { 1, 26, 1, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
- { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
n.feed('ggo<esc>')
eq(5, exec_lua('return #parser:children().c:trees()'))
eq({
{ 0, 0, 8, 0 }, -- root tree
+ { 2, 26, 2, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ { 3, 29, 3, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
{ 4, 14, 4, 17 }, -- VALUE 123
{ 5, 15, 5, 18 }, -- VALUE1 123
{ 6, 15, 6, 18 }, -- VALUE2 123
- { 2, 26, 2, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
- { 3, 29, 3, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
end)
end)
@@ -613,11 +613,11 @@ int x = INT_MAX;
eq(2, exec_lua('return #parser:children().c:trees()'))
eq({
{ 0, 0, 7, 0 }, -- root tree
+ { 1, 26, 2, 66 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
{ 3, 14, 5, 18 }, -- VALUE 123
-- VALUE1 123
-- VALUE2 123
- { 1, 26, 2, 66 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
- -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
n.feed('ggo<esc>')
@@ -625,11 +625,11 @@ int x = INT_MAX;
eq(2, exec_lua('return #parser:children().c:trees()'))
eq({
{ 0, 0, 8, 0 }, -- root tree
- { 4, 14, 6, 18 }, -- VALUE 123
- -- VALUE1 123
- -- VALUE2 123
{ 2, 26, 3, 66 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
-- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
+ -- VALUE 123
+ { 4, 14, 6, 18 }, -- VALUE1 123
+ -- VALUE2 123
}, get_ranges())
n.feed('7ggI//<esc>')
@@ -638,10 +638,10 @@ int x = INT_MAX;
eq(2, exec_lua('return #parser:children().c:trees()'))
eq({
{ 0, 0, 8, 0 }, -- root tree
- { 4, 14, 5, 18 }, -- VALUE 123
- -- VALUE1 123
{ 2, 26, 3, 66 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
-- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
+ -- VALUE 123
+ { 4, 14, 5, 18 }, -- VALUE1 123
}, get_ranges())
end)
@@ -794,22 +794,22 @@ int x = INT_MAX;
eq(5, exec_lua('return #parser:children().c:trees()'))
eq({
{ 0, 0, 7, 0 }, -- root tree
+ { 1, 26, 1, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
{ 3, 14, 3, 17 }, -- VALUE 123
{ 4, 15, 4, 18 }, -- VALUE1 123
{ 5, 15, 5, 18 }, -- VALUE2 123
- { 1, 26, 1, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
- { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
n.feed('ggo<esc>')
eq(5, exec_lua('return #parser:children().c:trees()'))
eq({
{ 0, 0, 8, 0 }, -- root tree
+ { 2, 26, 2, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ { 3, 29, 3, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
{ 4, 14, 4, 17 }, -- VALUE 123
{ 5, 15, 5, 18 }, -- VALUE1 123
{ 6, 15, 6, 18 }, -- VALUE2 123
- { 2, 26, 2, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
- { 3, 29, 3, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
end)
end)
@@ -831,11 +831,11 @@ int x = INT_MAX;
eq('table', exec_lua('return type(parser:children().c)'))
eq({
{ 0, 0, 7, 0 }, -- root tree
+ { 1, 26, 1, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
{ 3, 16, 3, 16 }, -- VALUE 123
{ 4, 17, 4, 17 }, -- VALUE1 123
{ 5, 17, 5, 17 }, -- VALUE2 123
- { 1, 26, 1, 63 }, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
- { 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
end)
it('should list all directives', function()