Fix malformed pattern check for group patterns in tokenizer

If the token type was a simple string (and not a table), the size of the 
string was used instead of `1`.
This commit is contained in:
Guldoman 2022-06-15 19:33:58 +02:00
parent d8a3987aa4
commit 5027a0f12b
No known key found for this signature in database
GPG Key ID: EA928C8BDA1A8825
1 changed files with 9 additions and 9 deletions

View File

@ -259,7 +259,8 @@ function tokenizer.tokenize(incoming_syntax, text, state)
local matched = false
for n, p in ipairs(current_syntax.patterns) do
local find_results = { find_text(text, p, i, true, false) }
if #find_results - 1 > #p.type then
if find_results[1] then
if #find_results - 1 > (type(p.type) == "table" and #p.type or 1) then
if not bad_patterns[current_syntax] then
bad_patterns[current_syntax] = { }
end
@ -268,7 +269,6 @@ function tokenizer.tokenize(incoming_syntax, text, state)
core.error("Malformed pattern #%d in %s language plugin", n, current_syntax.name or "unnamed")
end
end
if find_results[1] then
-- matched pattern; make and add tokens
push_tokens(res, current_syntax, p, text, find_results)
-- update state if this was a start|end pattern pair