mirror of
https://github.com/neovim/neovim.git
synced 2026-07-18 23:21:35 +00:00
fix(glob): handle numeric literals in pattern matching (#37257)
Problem:
vim.glob.to_lpeg() errors when patterns contain numeric literals
(like the '1' in '.ps*1') because LPeg interprets numeric strings
as indexed grammar rule references. For example:
vim.glob.to_lpeg('.ps*1')
E5108: Lua: rule '1' undefined in given grammar
Solution:
Prefix all rule names with '_' in the end_seg() function to prevent
literal numbers from being interpreted as LPeg indexed rules. This
ensures pattern components like '1', '2', etc. are treated as
regular rule names rather than special references.
This commit is contained in:
@@ -67,6 +67,9 @@ describe('glob', function()
|
||||
eq(true, match('a*b*[cy]*d*e*', 'axbxcxdxexxx'))
|
||||
eq(true, match('a*b*[cy]*d*e*', 'axbxyxdxexxx'))
|
||||
eq(true, match('a*b*[cy]*d*e*', 'axbxxxyxdxexxx'))
|
||||
eq(true, match('.ps*1', '.ps1'))
|
||||
eq(true, match('.ps*1', '.psaa1'))
|
||||
eq(false, match('.ps*1', '.ps1a'))
|
||||
end)
|
||||
|
||||
it('should match ? wildcards', function()
|
||||
|
||||
Reference in New Issue
Block a user