aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/highlight_spec.lua
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2025-02-10 18:31:40 -0800
committerLewis Russell <me@lewisr.dev>2025-02-11 09:17:08 +0000
commit3abfaafad255079f39a0843fb1b601db00d739af (patch)
tree4371c4222d389b422f3f625ac7c29b822d91bb54 /test/functional/treesitter/highlight_spec.lua
parentf8cbdbb4a817c9e85386c50ddf31460e49038c21 (diff)
downloadrneovim-3abfaafad255079f39a0843fb1b601db00d739af.tar.gz
rneovim-3abfaafad255079f39a0843fb1b601db00d739af.tar.bz2
rneovim-3abfaafad255079f39a0843fb1b601db00d739af.zip
fix(treesitter): detect trees with outdated regions in `is_valid()`
Diffstat (limited to 'test/functional/treesitter/highlight_spec.lua')
-rw-r--r--test/functional/treesitter/highlight_spec.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index 7f0a3cb342..02b50fd80e 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -891,6 +891,39 @@ describe('treesitter highlighting (lua)', function()
]],
})
end)
+
+ it('removes outdated highlights', function()
+ insert('-- int main() {}' .. string.rep("\nprint('test')", 20) .. '\n-- int other() {}')
+
+ exec_lua(function()
+ vim.cmd.norm('gg')
+ vim.treesitter.query.set(
+ 'lua',
+ 'injections',
+ [[((comment_content) @injection.content
+ (#set! injection.combined)
+ (#set! injection.language "c"))]]
+ )
+ vim.bo.filetype = 'lua'
+ vim.treesitter.start()
+ end)
+
+ screen:expect([[
+ {18:^-- }{16:int}{18: }{25:main}{16:()}{18: }{16:{}} |
+ {16:print(}{26:'test'}{16:)} |*16
+ |
+ ]])
+
+ exec_lua(function()
+ vim.cmd.norm('gg0dw')
+ end)
+
+ screen:expect([[
+ {25:^int} {25:main}{16:()} {16:{}} |
+ {16:print(}{26:'test'}{16:)} |*16
+ |
+ ]])
+ end)
end)
describe('treesitter highlighting (help)', function()