aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/glob_spec.lua
diff options
context:
space:
mode:
authorZoltán Nyikos <nyikoszoltan0@gmail.com>2024-07-06 11:40:08 +0200
committerGitHub <noreply@github.com>2024-07-06 11:40:08 +0200
commitb109b1abce8c86f80aea06948b32e35a70daa0b0 (patch)
tree952e9d3c495cad713618b817d2f031aef43d452c /test/functional/lua/glob_spec.lua
parent0abaccb2a795c40cd7f55b9a19fe6ecb765479e2 (diff)
downloadrneovim-b109b1abce8c86f80aea06948b32e35a70daa0b0.tar.gz
rneovim-b109b1abce8c86f80aea06948b32e35a70daa0b0.tar.bz2
rneovim-b109b1abce8c86f80aea06948b32e35a70daa0b0.zip
fix(glob): avoid `subcapture nesting too deep` error (#29520)
Use Cmt to evaluate Cond and Elem during match to avoid building the nested capture structure later.
Diffstat (limited to 'test/functional/lua/glob_spec.lua')
-rw-r--r--test/functional/lua/glob_spec.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/functional/lua/glob_spec.lua b/test/functional/lua/glob_spec.lua
index b3e1b79ee7..b95d874bb5 100644
--- a/test/functional/lua/glob_spec.lua
+++ b/test/functional/lua/glob_spec.lua
@@ -205,6 +205,19 @@ describe('glob', function()
eq(true, match('[!a-zA-Z0-9]', '!'))
end)
+ it('should handle long patterns', function()
+ -- lpeg has a recursion limit of 200 by default, make sure the grammar does trigger it on
+ -- strings longer than that
+ local fill_200 =
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
+ eq(200, fill_200:len())
+ local long_lit = fill_200 .. 'a'
+ eq(false, match(long_lit, 'b'))
+ eq(true, match(long_lit, long_lit))
+ local long_pat = fill_200 .. 'a/**/*.c'
+ eq(true, match(long_pat, fill_200 .. 'a/b/c/d.c'))
+ end)
+
it('should match complex patterns', function()
eq(false, match('**/*.{c,h}', ''))
eq(false, match('**/*.{c,h}', 'c'))